How Do I Sort Records By A Specific Key's Values?
You can sort the rows of a data grid form using the SortDataByKey command. Let's look at an example.
This card has a data grid and an option menu. The option menu contains three values that you can sort by: First Name, Last Name and Title.
Option Menu Code
The code to perform the sort is pretty straight forward.
1) Determine which array key of the data grid form to sort by. This will be one the keys you created when you assigned the dgData. If you used the dgText property then the key will be "Label 1" or "Label 2", etc.
2) Determine the sort type, direction and whether or not the sort is case sensitive.
3) Call the SortDataByKey command.
Here is what the sort looks like after selecting First Name.
I've tried to sort the records by a date field. Of course my dates are formatted dd/mm/yyyy (European style). The sort doesn't seem to work right. The records are not sorted according to the English format (the years are not sorted right).
set the useSystemDate to true
dispatch "SortDataByKey" to group "DataGrid1" with "theDate","dateTime","ascending","false"
dispatch "RefreshList" to group "DataGrid1"
Any idea what can be wrong?
@Franços - useSystemDate is a local property meaning it won't affect the code that is running in the SortDataByKey handler you send to the data grid. Rather than passing in "dateTime" try passing in "system date time".