Problem after datagrid form sort

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: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Problem after datagrid form sort

Post by Traxgeek » Fri Sep 06, 2013 5:07 pm

Further to my recent problems with DataGrid forms :

I've managed to sort my DataGrid by Key with a:
dispatch "sortDataByKey" to group "myDataGrid" with "myKey", "International", "Ascending/Descending", "False"

but... when I then click / select a specific item/row I'm parsed the data from the wrong dgIndex.
If I remove the sort then everything works just dandy... add the sort and my line/row selection goes to pot...

What I'm trying to do is pass all the relevant data on a specific item into a DataGrid but only displaying enough of it to enable the user to select the item they want to see. Clicking on the required line/row should (well, it does when I don't sort the data) open a group of items that displays the item in full... well, that's the idea but, like I say, I can't get it work after a sort...

Any ideas please ?
Last edited by Traxgeek on Sat Sep 07, 2013 4:40 pm, edited 1 time in total.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Problem after datagrid form sort

Post by Klaus » Sat Sep 07, 2013 2:11 pm

Hi Trax,

what did you script "on mouseup" that does not work correctly after a sort?
Be sure to query the current dg INDEX and not LINE, which may of course change after a sort!

Best

Klaus

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: Problem after datagrid form sort

Post by Traxgeek » Sat Sep 07, 2013 4:32 pm

Hi Klaus,

Before sorting (SortDataByKey), my MouseUp script works as expected. After a sort it fails.

My 'on MouseUp' script looks like :

on MouseUp
local sData

put the dgDataOfLine[the dgindex of me] of me into sData
Display_DetailedDGData sData --pass the complete data subset (for this DG row) to my detailed data display script...
end MouseUp

When I remark out the sort, populate the DG and select a line all works as expected...

Hope you can help.

Have a great weekend.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Problem after datagrid form sort

Post by Klaus » Sat Sep 07, 2013 11:29 pm

AHA!

the DGLine <> the DGIndex! 8)

Code: Select all

on MouseUp
  local sData

   ## Use this:
   put the dgDataOfIndex[the dgindex of me] of me into sData

   ## OR:
   ## put the dgDataOfLine[the dgLine of me] of me into sData
   ## But mixing them will cause some headache!

   Display_DetailedDGData sData --pass the complete data subset (for this DG row) to my detailed data display script...
end MouseUp
The Index stays "fix" where LINE (the visibke representation of a record) may change e.g. after a sort!


Best

Klaus

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: Problem after datagrid form sort

Post by Traxgeek » Sun Sep 08, 2013 10:40 pm

Ahhhhhhh.... thanks a million Klaus !
Must confess, hadn't noted the difference - have now (these datagrids; they're tricky critters !!
Brilliant - much appreciated.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Post Reply