DataGrid EditModeReorderCompleted how to

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bhall2001
Posts: 107
Joined: Thu Oct 30, 2014 3:54 pm
Location: Manchester, NH

DataGrid EditModeReorderCompleted how to

Post by bhall2001 » Fri May 21, 2021 12:25 pm

I am trying to figure out how to decipher the datagrid data after reordering of items using the message EditModeReorderCompleted. I have a very simple DataGrid (form) with a single item "Label" in a row. The data is just the letters a, b, c, d, e and f. I've got the reordering working no problem there and am able to receive the message (ps. on EditModeReorderCompleted needs to be in the DataGrid script not the row template script).

My goal is to end up with an array that represents the re-ordered list after a drag-reorder.

When I drag-reorder the rows and then look at the dgData of the datagrid, the elements of the dgData array are the original order of the letters, not the re-ordered order of the letters. So, as an example, if I move 'a' to row 3 on the screen, the dgData still shows 'a' at position 1 of the array.

The dgText of the datagrid returns the newly ordered list correctly. I see the message has 3 parameters. I presume there is some way to use the parameters to get what I'm looking for. Of course I could also turn the dgText into the array I need (but that feels dirty).

Can anyone help me with a clean way to get the re-ordered rows into an array? How do I get dgData to have the reordered list of elements? Is using the dgText the best way to do it?

Thanks in advance,
Bob H.

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

Re: DataGrid EditModeReorderCompleted how to

Post by dunbarx » Fri May 21, 2021 2:30 pm

Hi.

Can you find another message that is sent to the DG after the reordering? I rarely use these, so I am not sure whether something simple like "mouseUp" might be sent to the group later than other messages in the DG API, especially those "reOrder" types.

Otherwise, it should not matter whether you use the dgText or the dgData. The latter is an array, so you may need less post-processing, but the DG itself, and LC ultimately, does not care.

I usually use the dgText, finding it simpler for my needs.

Craig

bhall2001
Posts: 107
Joined: Thu Oct 30, 2014 3:54 pm
Location: Manchester, NH

Re: DataGrid EditModeReorderCompleted how to

Post by bhall2001 » Fri May 21, 2021 9:10 pm

Thanks for the response Craig.

I did try using other messages but I had the same result. dgText has the reordered list but dgData has the original ordering. I was hoping to use dgData as you pointed out, to reduce post processing. I'm just confused why dgData doesn't show the re-ordered list.

Bob

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

Re: DataGrid EditModeReorderCompleted how to

Post by dunbarx » Sat May 22, 2021 4:17 am

Trevor, if you are seeing this?
I'm just confused why dgData doesn't show the re-ordered list.
Craig

bhall2001
Posts: 107
Joined: Thu Oct 30, 2014 3:54 pm
Location: Manchester, NH

Re: DataGrid EditModeReorderCompleted how to

Post by bhall2001 » Sat May 22, 2021 11:58 am

Of course I should of included these deets in my original post:

Mac OS 11.14.1
LC 9.6.2

Bob

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

Re: DataGrid EditModeReorderCompleted how to

Post by Klaus » Sun May 23, 2021 2:47 pm

Hi Bob,

right after setting THE DGDATA or THE DGTEXT of a datagrid, the INDEX numbers are identical to the LINE numbers.
So you need to "swap" the appropriate keys (= line numbers = the numbers in the parameters of EDITMODEREORDERCOMPLETED)
of the DGDATA array.

Know what I mean?


Best

Klaus

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”