DataGrid EditModeReorderCompleted how to
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
DataGrid EditModeReorderCompleted how to
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.
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.
-
- VIP Livecode Opensource Backer
- Posts: 9665
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: DataGrid EditModeReorderCompleted how to
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
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
Re: DataGrid EditModeReorderCompleted how to
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
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
-
- VIP Livecode Opensource Backer
- Posts: 9665
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: DataGrid EditModeReorderCompleted how to
Trevor, if you are seeing this?
CraigI'm just confused why dgData doesn't show the re-ordered list.
Re: DataGrid EditModeReorderCompleted how to
Of course I should of included these deets in my original post:
Mac OS 11.14.1
LC 9.6.2
Bob
Mac OS 11.14.1
LC 9.6.2
Bob
Re: DataGrid EditModeReorderCompleted how to
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
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