DataGrid - drag & Drop rearranging order
Trevor DeVore
lists at mangomultimedia.com
Wed Sep 2 15:59:48 EDT 2009
On Sep 2, 2009, at 3:24 AM, Jim Sims wrote:
> On Sep 2, 2009, at 8:51 AM, Trevor DeVore wrote:
>>
>> Are you watching the conference today? I just might be posting an
>> updated data grid with built in support for this and showing how to
>> do it :-)
>
> Unfortunately I will not be watching it.
>
> How soon will that feature become available? I need to have rows
> with a few words and one image that can be rearranged in order -
> that would be extremely helpful for a project I'm working on.
You can download the test version I shared at the conference here:
<http://www.bluemangolearning.com/download/revolution/tools/revdatagridlibrary.rev.zip
>
This lesson shows how to upgrade it:
<http://revolution.screenstepslive.com/spaces/revolution/buckets/tutorials/lessons/6186-Upgrading-the-Data-Grid-Library
>
After installing the update you can add the following dragStart
handler to your data grid group.
on dragStart
put the dgDataControl of the target into theDataControl
## Watch out for dragging on the header
if theDataControl is empty then pass dragStart
## Get Data Grid index of control that was clicked on
put the dgIndex of the dgDataControl of the target into theIndex
## Tell Data Grid to set the dragImage to the row
## that theIndex is associated with
set the dgDragImageIndex of me to theIndex
## Set the dragData["private"] so that drag operation begins
set the dragData["private"] to empty
## Tell Data Grid to track drag reordering
set the dgTrackDragReorder[theIndex] of me to true
end dragStart
After the user reorders a line the Data Grid will receive the
DragReorderDrop message. Here is the basic code that will set the new
line position of the row that was dragged and redraw the grid.
on DragReorderDrop pOriginatingIndex, pStartLine, pDroppedOnLine
if pStartLine is not pDroppedOnLine then
## Tell data grid about new order
SetLineOfIndex pOriginatingIndex, pDroppedOnLine
## redraw the data grid after this message has finished running
send "RefreshList" to me in 0 seconds
end if
end DragReorderDrop
--
Trevor DeVore
Blue Mango Learning Systems
More information about the use-livecode
mailing list