Drag and drop within the same Grid in a Visual LANSA component
Posted: Wed Sep 19, 2018 1:29 am
I have been trying to write a simple VL Form that shows how to move a grid list entry within the displayed list by simply dragging and dropping the entry from one location to another. So far, I have not been able to make things work. I am unable to retrieve the current row number where the drop will take place. Here is my VL Form:
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientwidth(484) Clientheight(438) Componentversion(2) Left(850) Top(187)
Define_Com Class(#PRIM_GRID) Name(#Grid1) Captionnoblanklines(True) Columnscroll(False) Componentversion(1) Displayposition(1) Left(16) Parent(#COM_OWNER) Showselection(True) Showselectionhilight(False) Showsortarrow(True) Tabposition(1) Top(8) Height(385) Width(217) Columnbuttonheight(33) Selectionstyle(WholeRow) Dragcolumns(True) Dragstyle(Automatic)
Define_Com Class(#PRIM_GDCL) Name(#GridColumn1) Displayposition(1) Parent(#Grid1) Source(#EMPNO) Width(32)
Define_Com Class(#PRIM_GDCL) Name(#GridColumn2) Displayposition(2) Parent(#Grid1) Source(#SALARY) Width(41) Widthtype(Remainder)
Define_Com Class(#PRIM_STBR) Name(#StatusBar1) Displayposition(2) Height(24) Left(0) Messageposition(1) Parent(#COM_OWNER) Tabposition(2) Tabstop(False) Top(414) Width(484)
Define Field(#HoverEntry) Reffld(#std_num)
Define Field(#WEMPNO) Reffld(#EMPNO)
Define Field(#WSalary) Reffld(#Salary)
Def_List Name(#wrklst) Fields(#EMPNO #SALARY) Type(*WORKING) Entrys(1)
Evtroutine Handling(#com_owner.CreateInstance)
Select Fields(#Grid1) From_File(PSLMST)
Add_Entry To_List(#Grid1)
Endselect
#grid1.DragStyle := Automatic
Endroutine
Evtroutine Handling(#Grid1.StartDrag) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
#std_num := #Grid1.CurrentItem.Entry
Clr_List Named(#wrklst)
Add_Entry To_List(#wrklst)
Endroutine
Evtroutine Handling(#Grid1.DragDrop) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
Dlt_Entry Number(#STD_NUM) From_List(#Grid1)
Get_Entry Number(1) From_List(#wrklst)
Add_Entry To_List(#Grid1) After(#HoverEntry)
Endroutine
Evtroutine Handling(#grid1.DragOver) Acceptdrop(#AcceptDrop)
Set Com(#AcceptDrop) Value(True)
Endroutine
Evtroutine Handling(#Grid1.MouseHover) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
#HoverEntry := #Grid1.FocusItem.Entry
Endroutine
End_Com
I was wondering if anyone else has done this? Can you share your code?
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientwidth(484) Clientheight(438) Componentversion(2) Left(850) Top(187)
Define_Com Class(#PRIM_GRID) Name(#Grid1) Captionnoblanklines(True) Columnscroll(False) Componentversion(1) Displayposition(1) Left(16) Parent(#COM_OWNER) Showselection(True) Showselectionhilight(False) Showsortarrow(True) Tabposition(1) Top(8) Height(385) Width(217) Columnbuttonheight(33) Selectionstyle(WholeRow) Dragcolumns(True) Dragstyle(Automatic)
Define_Com Class(#PRIM_GDCL) Name(#GridColumn1) Displayposition(1) Parent(#Grid1) Source(#EMPNO) Width(32)
Define_Com Class(#PRIM_GDCL) Name(#GridColumn2) Displayposition(2) Parent(#Grid1) Source(#SALARY) Width(41) Widthtype(Remainder)
Define_Com Class(#PRIM_STBR) Name(#StatusBar1) Displayposition(2) Height(24) Left(0) Messageposition(1) Parent(#COM_OWNER) Tabposition(2) Tabstop(False) Top(414) Width(484)
Define Field(#HoverEntry) Reffld(#std_num)
Define Field(#WEMPNO) Reffld(#EMPNO)
Define Field(#WSalary) Reffld(#Salary)
Def_List Name(#wrklst) Fields(#EMPNO #SALARY) Type(*WORKING) Entrys(1)
Evtroutine Handling(#com_owner.CreateInstance)
Select Fields(#Grid1) From_File(PSLMST)
Add_Entry To_List(#Grid1)
Endselect
#grid1.DragStyle := Automatic
Endroutine
Evtroutine Handling(#Grid1.StartDrag) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
#std_num := #Grid1.CurrentItem.Entry
Clr_List Named(#wrklst)
Add_Entry To_List(#wrklst)
Endroutine
Evtroutine Handling(#Grid1.DragDrop) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
Dlt_Entry Number(#STD_NUM) From_List(#Grid1)
Get_Entry Number(1) From_List(#wrklst)
Add_Entry To_List(#Grid1) After(#HoverEntry)
Endroutine
Evtroutine Handling(#grid1.DragOver) Acceptdrop(#AcceptDrop)
Set Com(#AcceptDrop) Value(True)
Endroutine
Evtroutine Handling(#Grid1.MouseHover) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
#HoverEntry := #Grid1.FocusItem.Entry
Endroutine
End_Com
I was wondering if anyone else has done this? Can you share your code?