Display and sort data in repeating table on Print view

P

Patrick

I have a form with a repeating table, when data is entered it is not in Alpha
order, When I switch to the print view I need the data to be listed in Alpha
order. I am new to this so any help would be appreciated.
 
S

Scott L. Heim [MSFT]

Hi Patrick,

You will need to create custom code to execute the sort - unless your
InfoPath form is based on a database or web service. Assuming this is not
the case, take a look at the "Asset Tracking" sample that ships with
InfoPath as it has a custom sort routine.

I hope this helps!

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Patrick

If it is based on a database, how would I go about it. I appologize if the
questions are elemetary I am new to this and not a programmer. So writing
custom code is going to be tough. Any help would be appreciated.
 
S

Scott L. Heim [MSFT]

Hi Patrick,

If your form is based on a database then you could create a "query"
(Access" or a "view" (SQL) that returns the records in the order you
specify. Then you may be able to change the data source of your InfoPath
solution to the query or view.

I hope this helps!

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Patrick

I have tried to rip the sort code out of the example that you mentioned. It
does exactly what I am trying to do except I only need it to sort on one
field, ever. But I keep getting an object expected error, and can't seem to
isolate the part of the code that I need.

P
 
S

Scott L. Heim [MSFT]

Hi Patrick,

Try this:

- Make a copy of the Asset Tracking sample
- Make sure this still works as you need
- Optional: Remove all entries from the "sort" drop-down boxes except for:
at:category
- Open the Microsoft Script Editor
- Locate the following line of code in the btnReSort::OnClick event:

g_xpathSortBy = getNodeValue("/at:assetTracking/at:tempSortBy");

- Comment this line and place it with:

g_xpathSortBy = "at:category";

- Save and close the script editor
- Save the new sample
- Double-click the XSN, add some data and test...you should see that your
data is sorted by Category.

Now, the main reason for this exercise is to insure that having just one
item in the drop-down does indeed work but also to demonstrate that even
though you have just one item, you would probably still want to use a
drop-down list so you can display a "friendly" name of how the data is
being sorted. That is, unless you just want to remove it completely from
the form.

Based on the behavior you described, it sounds like your XPath may be in
error. Add the line: debugger; to your button's click event and use the
"F11" key to step through the code to see exactly what line is failing.

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top