How to drag-reorder rows in a Data Grid?

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
smartvn2020
Posts: 1
Joined: Thu Nov 12, 2020 8:38 am

How to drag-reorder rows in a Data Grid?

Post by smartvn2020 » Thu Nov 12, 2020 8:42 am

How do I drag-reorder rows in a Data Grid? I have to ask because, of course, it's not documented. I Googled and found some 10-year old threads but the code there didn't work for me.

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

Re: How to drag-reorder rows in a Data Grid?

Post by dunbarx » Thu Nov 12, 2020 3:48 pm

Trevor may chime in here, but I believe you have to kludge this. Something like (super-pseudo)"

Code: Select all

on mouseDown put the value of the  "mouseLine" into startLine
create a phantom field containing startLine
on mouseMove set the y value of the phantom to the mouseV
on mouseUp put the value of the mouseLine into endLine
get the dgText of the DG
switch the contents of the two lines
set the dgText to the new configuration
Seems easy...

Craig

elanorb
Livecode Staff Member
Livecode Staff Member
Posts: 516
Joined: Fri Feb 24, 2006 9:45 am

Re: How to drag-reorder rows in a Data Grid?

Post by elanorb » Thu Nov 12, 2020 5:33 pm

Hi

Data grid forms now have a dgEditMode property. When in edit mode, the data grid displays an action control of the left hand side of each row and a reorder control on the right that allows you to drag-reorder rows.

We have a lesson on this here

https://lessons.livecode.com/m/datagrid ... -data-grid

If you just want the re-order control and not the action control you can do

Code: Select all

set the dgProps["edit mode action select control"] of group "Data Grid Form" to empty
I hope that helps.

Elanor
Elanor Buchanan
Software Developer
LiveCode

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

Re: How to drag-reorder rows in a Data Grid?

Post by dunbarx » Thu Nov 12, 2020 5:52 pm

Well, if not Trevor, then Elanor.

Craig

elanorb
Livecode Staff Member
Livecode Staff Member
Posts: 516
Joined: Fri Feb 24, 2006 9:45 am

Re: How to drag-reorder rows in a Data Grid?

Post by elanorb » Thu Nov 12, 2020 6:25 pm

I was just passing :)
Elanor Buchanan
Software Developer
LiveCode

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”