Page 1 of 1

Data grid sorting

Posted: Wed Sep 02, 2015 7:36 am
by shalu

I am beginner in LiveCode, My problem is I don't know how to sort the data grid, eg: I have data grid contains id, name, accepted date, submit date, I want to sort(ascending order or descending order) the entire data grid according to the accepted date. :oops:

Re: Data grid sorting

Posted: Wed Sep 02, 2015 8:57 am
by msellke
Hi Shalu,
There are a number of ways to sort the datagrid.
If you are only new to Livecode and therefore new to Datagrids can I suggest you look at a plugin called Datagrid Helper.
It is very handy when it comes to formatting the datagrid.


Re: Data grid sorting

Posted: Wed Sep 02, 2015 1:54 pm
by dunbarx

I always bring the data out into the clear and work on it directly within LC. I do this with either the "dgText" or the "dgData". Read about these in the DG User Guide. Something like:

Code: Select all

set the itemDel to tab
put the dgText of group "yourDataGrid" into yourVariable
sort yourVariable by item 1 of each -- would sort by the first column 
set the dgText of group "yourDataGrid" to yourVariable
There is much that can be done within the DG. There is much more that can be done (temporarily) outside it.

Craig Newman

Re: Data grid sorting

Posted: Thu Sep 03, 2015 2:44 pm
by Klaus
HI shalu,

datagrids are higly complex so I recommend to load the docs as a PDF here:
and work through it a couple of time :D

To sort your datagrid via script, you can use the datagrid command:
SortDataByKey pArrayKey, pSortType, pDirection, pCaseSensitive

Do like this:

Code: Select all

## Sort your data by column "accepted date", sort by date, ascending, NOT case sensitive
dispatch "SortDataByKey" to grp "your datagrid here..." with "accepted date", "dateTime", "ascending", "false"