Sort of a data grid under program control

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Sort of a data grid under program control

Post by lohill » Wed Aug 22, 2012 11:21 pm

If I put the following command in the openCard event of a card:

dispatch "SortDataByKey" to group "DataGrid 1" with "Port Date", "datetime", "ascending"

When the card is finished opening, DataGrid 1 is sorted in ascending order of the column "Port Date"
However, if the last time the card had been open it had been sorted by the field "Value", the heading of the column "Value" would still appear as dark grey with the tick mark showing direction of sort for "Value" even though the actual sort was on "Port Date".

Is there a parameter that I am missing or another command that can be given to the header to make it reflect the sort that was done under program control?

Regards,
Larry

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Sort of a data grid under program control

Post by bangkok » Thu Aug 23, 2012 6:12 am

lohill wrote: Is there a parameter that I am missing or another command that can be given to the header to make it reflect the sort that was done under program control?
Yes. Add :

Code: Select all

  set the dgProp["sort by column"] of group "DataGrid 1"  to "Port Date"

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: Sort of a data grid under program control

Post by lohill » Thu Aug 23, 2012 11:45 pm

Thanks bangkok!

Larry

Post Reply