How Do I Dynamically Change the Display Order of Records in a Program? (Magic xpa 3.x)
The record display order can be determined two ways: by creating a runtime Sort in the Sort window or, more commonly, by selecting different indexes in the properties of the Main Source. In this example, we selected Index 1, so the records will be sorted by the Customer Code.
However, you can also set the index dynamically, using an expression. This is commonly done so the user can change the display order of a table, or to optimize processing time depending on what filters the user chose for a report.
-
Go to Data View, and position on the Main Source. Press Alt+Enter. You will be on the Properties of Main Source.
-
Type 0 (zero) in the Index field. That will allow you to tab over to the right, where the index expression can be coded.
-
Zoom from the index expression, or press the fx button.
-
Enter your index expression. Here we are selecting index 1 if the sort order is āIā (for ID); otherwise we use index 2. Using the format '1'INDEX ensures that if the indexes are moved in the data source, the expression will remain correct.
-
Click OK, which will bring the expression number back to the properties pane.
Note: Users also have the option of clicking on a column header to change the sort order of displayed records, or creating their own sort order using Ctrl+T (Options->Sort Records) when using the End User Functionality component.
How Can I Dynamically Set the Order of the Retrieved Records in a Task?
The Online and Rich Client Samples projects (program TS05 and RTS05)