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
Posts: 72
Joined: Fri Mar 20, 2015 1:05 pm

Data grid sorting

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


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

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.


VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7310
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


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

Posts: 12124
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany

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:
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"


Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”