Data grid sorting

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
shalu
Posts: 72
Joined: Fri Mar 20, 2015 1:05 pm

Data grid sorting

Post by shalu » Wed Sep 02, 2015 7:36 am

Hi,

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:
--
Thanks
Shalu S

msellke
Posts: 22
Joined: Mon Oct 21, 2013 2:57 am

Re: Data grid sorting

Post by msellke » Wed Sep 02, 2015 8:57 am

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.

Cheers,
Matt

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5991
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Data grid sorting

Post by dunbarx » Wed Sep 02, 2015 1:54 pm

hi.

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

Klaus
Posts: 10971
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Data grid sorting

Post by Klaus » Thu Sep 03, 2015 2:44 pm

HI shalu,

datagrids are higly complex so I recommend to load the docs as a PDF here: http://lessons.runrev.com/m/datagrid
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"
...
Best

Klaus

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”