VL-WEB move entry up and down i list
Posted: Sat Mar 25, 2017 12:59 am
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. If I click on the down arrow in entry number 5 I get this result 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
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. If I click on the down arrow in entry number 5 I get this result 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