Datagrid Table - How to read the row order

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Simon Knight
Posts: 934
Joined: Wed Nov 04, 2009 11:41 am

Datagrid Table - How to read the row order

Post by Simon Knight »

Hi,

I have been reading the Datagrid API but still seek enlightenment. I have a standard datagrid table that allows the user to sort the rows by selecting the column headings. I wish to extract the data in the same order as it is being displayed. The simple answer is to use the dgText[true] command which returns a TSV copy of the data in the display order with headings.

Code: Select all

put the dgText[true] of group "dgNotes" into tData -- TSV in display order
So thats o.k. ??

However, the API implies that the dgText command is for wimps "in the interest of making life easier for some folks there is the dgText property". So real non-folksy (is that a word?) programmers use the dgData property.

Code: Select all

put the dgData of group "dgNotes" into tDataA
As far as I can see this returns the data in an unordered array.

The property "sort by column" returns the column being used to sort the data but it does not return the sort direction i.e. ascending / descending and I cannot find a property that does return the direction.

Code: Select all

put the dgProp["sort by column"] of group "dgnotes" into tSortCol
Now I expect that I have missed something obvious, can you shed some light or am I just going to accept that I am one of those folks who uses dgText?
best wishes
Skids
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: Datagrid Table - How to read the row order

Post by dunbarx »

I use the dgText all the time. I am a wimp.

If you extract the dgData, the only thing you can do is sort the keys of that array, which may or may not get you where you need to be. You would have to transform the array into an ordinary variable using the "combine" command, and then use all of LC's tools from there.

Wimps unite!

Craig Newman
Simon Knight
Posts: 934
Joined: Wed Nov 04, 2009 11:41 am

Re: Datagrid Table - How to read the row order

Post by Simon Knight »

A folksy wimp - whatever next ?!

Does seem to be an omission from the API - user is sorting on column "fred" but I'm not going to tell you in which direction. (Do you feel lucky???)

dgtext rules

Simon K
best wishes
Skids
Post Reply