Page 1 of 1

VL-WEB move entry up and down i list

Posted: Sat Mar 25, 2017 12:59 am
by kno_dk
Hi.
I have this small application, where I have to move an entry up or down in a list. it looks like this at start up. The first line do not have a up arrow and the last don't have down arrow.
updown1.PNG
updown1.PNG (17.35 KiB) Viewed 1218 times
If I click on the down arrow in entry number 5 I get this result
updown2.PNG
updown2.PNG (17.94 KiB) Viewed 1218 times
the data is move correct but the image in entry 5 and 6 is not correct.
I have tried differnt things but none has worked perfect.

hope somebody can help!

Here is my last version of the code:

Begin_Com Role(*EXTENDS #PRIM_WEB) Layoutmanager(#TableLayout_Main) Width(600) Height(240)

Define Field(#sidsteentry) Reffld(#LISTCOUNT)

Define_Com Class(#PRIM_TBLO) Name(#TableLayout_Main)
* Layout Columns and Rows
Define_Com Class(#PRIM_TBLO.Column) Name(#Column1) Displayposition(1) Parent(#TableLayout_Main)
Define_Com Class(#PRIM_TBLO.Row) Name(#Row2) Displayposition(2) Parent(#TableLayout_Main) Height(1,72)
Define_Com Class(#PRIM_TBLO.Row) Name(#Row1) Displayposition(1) Parent(#TableLayout_Main) Height(40) Units(Pixels)

* Layout Items

Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem1) Column(#Column1) Manage(#List1) Parent(#TableLayout_Main) Row(#Row2)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem2) Alignment(CenterLeft) Column(#Column1) Flow(Right) Parent(#TableLayout_Main) Row(#Row1) Sizing(None)

Define_Com Class(#PRIM_LIST) Name(#List1) Displayposition(1) Height(200) Left(0) Parent(#COM_OWNER) Tabposition(1) Top(40) Width(600) Rowheight(22)
Define_Com Class(#PRIM_LIST.String) Name(#ColumnK3VARN) Displayposition(3) Parent(#List1) Source(#K3VARN)
Define_Com Class(#PRIM_LIST.String) Name(#ColumnITATXT1) Displayposition(4) Parent(#List1) Source(#ITATXT) Columnwidth(262)
Define_Com Class(#PRIM_LIST.Image) Name(#SletImage) Columnwidth(26) Displayposition(5) Parent(#List1) Image(#EOIDeleteImage) Imagesizing(BestFit)
Define_Com Class(#PRIM_LIST.Number) Name(#ColumnK3SORT1) Displayposition(6) Increment(1) Parent(#List1) Source(#k3sort) Wrap(False)

Define_Com Class(#PRIM_LIST.Image) Name(#Flyt_op) Columnwidth(25) Displayposition(1) Parent(#List1) Image(#EOI_arrowUp) Imagesizing(BestFit) Cellwidth(10) Cellheight(32)
Define_Com Class(#PRIM_LIST.Image) Name(#Flyt_ned) Columnwidth(25) Displayposition(2) Parent(#List1) Image(#EOI_arrowDown) Imagesizing(BestFit) Cellwidth(32) Cellheight(32)


Def_List Name(#WEBGREFList) Fields(#K3VARN #K3GRP #k3sort #ITATXT) Counter(#ListCount) Type(*Working) Entrys(*Max)


Define Field(#i1) Type(*dec) Length(3) Decimals(0)
* ===================================================================
* Routines
* ===================================================================

* --------------------------------------------------------------------------------
* Handle Command Execution
* --------------------------------------------------------------------------------
Evtroutine Handling(#Com_owner.Initialize)

#Com_Owner.uSelectData

Endroutine

Mthroutine Name(uSelectData)

#K3VARN := A
#itatxt := AA
#k3sort := 1
Add_Entry To_List(#WEBGREFList)
#K3VARN := B
#itatxt := BB
#k3sort := 2
Add_Entry To_List(#WEBGREFList)
#K3VARN := C
#itatxt := CC
#k3sort := 3
Add_Entry To_List(#WEBGREFList)
#K3VARN := D
#itatxt := DD
#k3sort := 4
Add_Entry To_List(#WEBGREFList)
#K3VARN := E
#itatxt := EE
#k3sort := 5
Add_Entry To_List(#WEBGREFList)
#K3VARN := F
#itatxt := FF
#k3sort := 6
Add_Entry To_List(#WEBGREFList)


#sidsteentry := #LISTCOUNT
Clr_List Named(#List1)
*
Selectlist Named(#WEBGREFList)
Add_Entry To_List(#List1)
Endselect
Execute Subroutine(OpdatList)

Endroutine


Evtroutine Handling(#Flyt_ned.Click)
#List1.CurrentItem.Position += 1
#k3sort := #List1.currentitem.Position
Upd_Entry In_List(#List1)
Execute Subroutine(OpdatList)
Endroutine


Evtroutine Handling(#Flyt_op.Click)
#List1.CurrentItem.Position -= 1
#k3sort := #List1.currentitem.Position
Upd_Entry In_List(#List1)
Execute Subroutine(OpdatList)
Endroutine

* =======================================================
* Subroutine ....: OpdatList
* Description....: Opdatering af liste
* =======================================================
Subroutine Name(OpdatList)


#i1 := 0
For Each(#Item) In(#List1.Items)
#i1 += 1
Get_Entry Number(#Item.Entry) From_List(#List1)

#K3SORT := #i1

#ITATXT := #k3sort.AsString + ' / ' + #ITATXT
*
Upd_Entry In_List(#List1)

Endfor

If Cond(#LISTCOUNT *EQ 1)
Get_Entry Number(1) From_List(#List1)
#Flyt_op.CurrentItem.Image #Flyt_ned.CurrentItem.Image <= *null
#Flyt_op.CurrentItem.Enabled #Flyt_ned.CurrentItem.Enabled := False
*
Else
Begin_Loop Using(#i1) To(#LISTCOUNT)
Get_Entry Number(#i1) From_List(#List1)
#Flyt_op.CurrentItem.Image <= #EOI_arrowUp
#Flyt_ned.CurrentItem.Image <= #EOI_arrowDown
If ('#I1 *eq 1')
#Flyt_op.CurrentItem.image <= *Null
#Flyt_op.CurrentItem.Enabled := False
*
Endif
If ('(#I1 *eq #LISTCOUNT) ')
#Flyt_ned.CurrentItem.Image <= *null
#Flyt_ned.CurrentItem.Enabled := False
Endif

End_Loop
*
Endif
* Endselect
Endroutine
End_Com

Re: VL-WEB move entry up and down i list

Posted: Sat Mar 25, 2017 11:48 am
by Stewart Marshall
The list will do a lot of work for you here, so you need only show/hide the images based on their position in the list

UPD_ENTRY is only required to change to underlying data state, so I've only used it to update the caption.

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_WEB) Width(825) Height(473) LayoutManager(#Layout1) Theme(#SYS_THEME<2015Green>)
Define_Com Class(#PRIM_TBLO) Name(#Layout1)
Define_Com Class(#PRIM_TBLO.Row) Name(#LayoutRow1) DisplayPosition(1) Parent(#Layout1)
Define_Com Class(#PRIM_TBLO.Column) Name(#LayoutColumn1) DisplayPosition(1) Parent(#Layout1)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem1) Column(#LayoutColumn1) Manage(#List) Parent(#Layout1) Row(#LayoutRow1)

Define_Com Class(#PRIM_LIST) Name(#List) DisplayPosition(1) Left(0) Parent(#COM_OWNER) TabPosition(1) Top(0) Height(473) Width(825) ColumnLines(False) RowLines(False)
Define_Com Class(#PRIM_LIST.Image) Name(#ColumnUp) ColumnWidth(50) DisplayPosition(1) Parent(#List) Image(#xImageUp16)
Define_Com Class(#PRIM_LIST.Image) Name(#ColumnDown) ColumnWidth(50) DisplayPosition(2) Parent(#List) Image(#xImageDown16)
Define_Com Class(#PRIM_LIST.Number) Name(#ColumnXDEMONUMB1) ColumnWidth(96) DisplayPosition(3) Increment(1) Parent(#List) Source(#xDemoNumber) Wrap(False)
Define_Com Class(#PRIM_LIST.String) Name(#ColumnXDEMOCAPT1) ColumnWidth(1707) DisplayPosition(4) Parent(#List) Source(#xDemoCaption)

Evtroutine Handling(#Com_owner.CreateInstance)

Begin_Loop Using(#xDemoNumber) To(10)

#xDemoCaption := ("Sort position #&1").Substitute( #xDemoNumber.AsString )

Add_Entry To_List(#List)

End_Loop

#Com_self.UpdateList

Endroutine

Evtroutine Handling(#ColumnDown.Click)

#List.CurrentItem.Position += 1
#Com_self.UpdateList

Endroutine

Evtroutine Handling(#ColumnUp.Click)

#List.CurrentItem.Position -= 1
#Com_self.UpdateList

Endroutine

Mthroutine Name(UpdateList)

Selectlist Named(#List)

#xDemoCaption := ("Sort position #&1").Substitute( #List.CurrentItem.Position.AsString )

Upd_Entry In_List(#List)

#ColumnUp.CurrentItem.Visible := #List.CurrentItem.Position <> 1
#ColumnDown.CurrentItem.Visible := #List.CurrentItem.Position <> #List.Items.ItemCount

Endselect

Endroutine

End_Com

Re: VL-WEB move entry up and down i list

Posted: Mon Mar 27, 2017 8:30 pm
by kno_dk
Thanks - it works perfectly!