Sorting a datagrid

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
dsquance
Posts: 40
Joined: Mon Jan 18, 2010 2:47 am

Sorting a datagrid

Post by dsquance »

I am trying to set up a button to sort the lines of a datagrid. The following is part of the script:

put orgchoice&"data" into thegroup ## orgchoice is a global variable, previously assigned
put orgchoice & " chq list" into thecard
put the dgtext of group thegroup of card thecard into dataset
sort lines of dataset numeric by word 1 of each
set the dgtext of group thegroup of card thecard to dataset

When I work with this in the message box, putting line 1 of dataset returns the correct line, but the datagrid is not being changed, ie the line I test is not the same as the line from dataset. Have I messed up the syntax somewhere?
Thanks, Dave
Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Re: Sorting a datagrid

Post by Janschenkel »

Take a look at the examples I put together on my blog for one way of handling sorting in a datagrid: HTH,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
dsquance
Posts: 40
Joined: Mon Jan 18, 2010 2:47 am

Re: Sorting a datagrid

Post by dsquance »

Thanks, Jan. I copied your script and pasted it into the datagrid script. However, clicking on a column header does not change the order of the lines, before or after refreshing. Perhaps there are some modifications I need to make, but am too much of an amateur to recognize. If nothing else, your comments before the script told me about sorting directly which worked for my datagrid. Of course, that's not available in the standalone.
Dave
dsquance
Posts: 40
Joined: Mon Jan 18, 2010 2:47 am

Re: Sorting a datagrid

Post by dsquance »

Looks like I posted too soon. It does appear to be working, however the heading for the first column has disappeared, and that's the column I want to sort by under non-testing conditions.
Dave
Post Reply