Drag line in list to new row
Hi Martin
This is the code in the $event method of MyList which I use to rearrange line positions within the list using drag and drop. :-
LocalVariables :-
DroppedOnSameLine Boolean False
LineNumber Number (Long Integer)
LineRef Item reference
Ensure the following properties are set :-
Do $cwind.$objs.MyList.$multipleselect.$assign(kTrue)
Do $cwind.$objs.MyList.$dragmode.$assign(kDragData)
Do $cwind.$objs.MyList.$hiliteline.$assign(kTrue)
Do $cwind.$objs.MyList.$dropmode.$assign(kAcceptList)
Do $cwind.$objs.MyList .$dropbetweenlines.$assign(kTrue)
Code behind list :-
On evWillDrop
If pDropField<>$cobj
Quit event handler (Discard event) ;; Only drag and drop to re-order fields is allowed.
End If
On evDrop
; Rearrange the order of the lines in the list :-
Calculate LineNumber as mouseover(kMLine)
Do pDragValue.$first(kTrue) ;; Sets the first selected line to be current.
While MyList.$line>0
Do pDragValue.$addbefore(LineNumber) Returns LineRef ;; Adds an empty line before the dropped line number.
If pDragValue.$line>LineNumber
Calculate pDragValue.$line as pDragValue.$line+1
End If
Do LineRef.$assignrow(pDragValue) ;; Assign the data form the current row to the new empty line
Calculate LineNumber as LineNumber+1
Do pDragValue.$next(pDragValue.$line,kTrue) ;; Make next selected line current
If pDragValue.$line=LineNumber
Calculate DroppedOnSameLine as kTrue
Break to end of loop
End If
End While
If DroppedOnSameLine
Do pDragValue.$remove(LineRef) ;; delete the inserted blank line
Else
Do pDragValue.$remove(kListDeleteSelected) ;; delete the original data
End If
Do $cinst.$redraw() ;; redraw list
Hope that helps
Regards
Alan Perrin
—–Original Message—–
From: omnisdev-en [mailto:omnisdev-en-bounces@lists.omnis-dev.com] On Behalf Of Martin Luce
Sent: 31 August 2017 11:14
To: Omnis List <omnisdev-en@lists.omnis-dev.com>
Subject: Drag line in list to new row
Hi
I am trying to reorder a list by by dragging a line from say line 5 to drop it into the position say between lines 2 and 3 in the same list, so that the dragged line becomes #L=3. Not getting much success. I can drag the line but it won’t drop into position. I am using 4.2.
If anyone could show me the event method for the list and perhaps a screen shot of the property action tab plus anything else I need to make it work, I would be very grateful.
Martin
_____________________________________________________________
Manage your list subscriptions at lists.omnis-dev.com