updating a list entry image column
updating a list entry image column
I have been attempting to update the image of a specific entry in a list (web). It will not change the image no matter what I do. I have attached a simple web page quickexport to show what I am trying to do. Please correct my mistakes!
- Attachments
-
- QuickExport20160318122150.zip
- (8.99 KiB) Downloaded 121 times
- Stewart Marshall
- Posts: 417
- Joined: Thu Nov 05, 2015 5:25 pm
Re: updating a list entry image column
Hi David
The image property for a column is used as prototype when you add an entry. If you subsequently change it it will have no effect on an existing item.
For specific item based processing, you must refer to the Currentitem. Prim_list is particularly flexible in this regard because both the list itself and the columns have a currentitem property. So, you can refer to column.currentitem.image. Corrected code is below.
I've also removed the selected := False line. I assume this was there to stop the list item appearing as selected. You can do as you did, but it's not particularly good practice as it messes with the lists own processing. Far better is to use a Theme and to create a drawstyle for a list item wherre the selected style has a transparent background.
Begin_Com Role(*EXTENDS #PRIM_WEB) Layoutmanager(#TableLayout) Width(529)
Define_Com Class(#PRIM_TBLO) Name(#TableLayout)
Define_Com Class(#PRIM_TBLO.Row) Name(#Row) Displayposition(1) Parent(#TableLayout)
Define_Com Class(#PRIM_TBLO.Column) Name(#Column) Displayposition(1) Parent(#TableLayout)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem1) Column(#Column) Manage(#List1) Parent(#TableLayout) Row(#Row)
Define_Com Class(#PRIM_LIST) Name(#List1) Displayposition(1) Height(800) Left(0) Parent(#COM_OWNER) Tabposition(1) Top(0) Width(529)
Define_Com Class(#PRIM_LIST.Image) Name(#ColumnImage1) Columnwidth(50) Displayposition(1) Parent(#List1) Imagesizing(BestFit)
Define_Com Class(#PRIM_LIST.String) Name(#ColumnSTD_TEXT1) Displayposition(2) Parent(#List1) Source(#STD_TEXT) Columnwidth(379)
Evtroutine Handling(#Com_owner.Initialize)
Begin_Loop To(10)
If (#List1.Items.ItemCount.mod( 2 ) = 1)
#STD_TEXT := 'No Image'
Else
#ColumnImage1.CurrentItem.image <= #VB_ARROWF
#STD_TEXT := 'Image Shown'
Endif
Add_Entry To_List(#List1)
End_Loop
Endroutine
Evtroutine Handling(#List1.ItemGotSelection)
If (#ColumnImage1.Currentitem.Image *Is *NULL)
#ColumnImage1.CurrentItem.Image <= #VB_ARROWF
#STD_TEXT := 'Image Shown'
Else
#ColumnImage1.CurrentItem.Image <= *NULL
#STD_TEXT := 'No Image'
Endif
Upd_Entry In_List(#List1)
Endroutine
End_Com
The image property for a column is used as prototype when you add an entry. If you subsequently change it it will have no effect on an existing item.
For specific item based processing, you must refer to the Currentitem. Prim_list is particularly flexible in this regard because both the list itself and the columns have a currentitem property. So, you can refer to column.currentitem.image. Corrected code is below.
I've also removed the selected := False line. I assume this was there to stop the list item appearing as selected. You can do as you did, but it's not particularly good practice as it messes with the lists own processing. Far better is to use a Theme and to create a drawstyle for a list item wherre the selected style has a transparent background.
Begin_Com Role(*EXTENDS #PRIM_WEB) Layoutmanager(#TableLayout) Width(529)
Define_Com Class(#PRIM_TBLO) Name(#TableLayout)
Define_Com Class(#PRIM_TBLO.Row) Name(#Row) Displayposition(1) Parent(#TableLayout)
Define_Com Class(#PRIM_TBLO.Column) Name(#Column) Displayposition(1) Parent(#TableLayout)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem1) Column(#Column) Manage(#List1) Parent(#TableLayout) Row(#Row)
Define_Com Class(#PRIM_LIST) Name(#List1) Displayposition(1) Height(800) Left(0) Parent(#COM_OWNER) Tabposition(1) Top(0) Width(529)
Define_Com Class(#PRIM_LIST.Image) Name(#ColumnImage1) Columnwidth(50) Displayposition(1) Parent(#List1) Imagesizing(BestFit)
Define_Com Class(#PRIM_LIST.String) Name(#ColumnSTD_TEXT1) Displayposition(2) Parent(#List1) Source(#STD_TEXT) Columnwidth(379)
Evtroutine Handling(#Com_owner.Initialize)
Begin_Loop To(10)
If (#List1.Items.ItemCount.mod( 2 ) = 1)
#STD_TEXT := 'No Image'
Else
#ColumnImage1.CurrentItem.image <= #VB_ARROWF
#STD_TEXT := 'Image Shown'
Endif
Add_Entry To_List(#List1)
End_Loop
Endroutine
Evtroutine Handling(#List1.ItemGotSelection)
If (#ColumnImage1.Currentitem.Image *Is *NULL)
#ColumnImage1.CurrentItem.Image <= #VB_ARROWF
#STD_TEXT := 'Image Shown'
Else
#ColumnImage1.CurrentItem.Image <= *NULL
#STD_TEXT := 'No Image'
Endif
Upd_Entry In_List(#List1)
Endroutine
End_Com
Re: updating a list entry image column
Many thanks for good example, it shows, how to refer the image via CurrentItem object.
But IMHO the example code is not fully correct. The reference to CurrentItem can be established after Add_entry or Get_Entry command, not before. You can omit (comment) the Evtroutine Handling(#List1.ItemGotSelection) to see what's wrong.
The corect logic segment applicable for list population should be:
If (#List1.Items.ItemCount.mod( 2 ) = 1)
#STD_TEXT := 'No Image'
Add_Entry To_List(#List1)
Else
#STD_TEXT := 'Image Shown'
Add_Entry To_List(#List1)
#ColumnImage1.CurrentItem.image <= #VB_ARROWF
Endif
The logic of list entry update in GotSelection EVTROUTINE is fully corect.
But IMHO the example code is not fully correct. The reference to CurrentItem can be established after Add_entry or Get_Entry command, not before. You can omit (comment) the Evtroutine Handling(#List1.ItemGotSelection) to see what's wrong.
The corect logic segment applicable for list population should be:
If (#List1.Items.ItemCount.mod( 2 ) = 1)
#STD_TEXT := 'No Image'
Add_Entry To_List(#List1)
Else
#STD_TEXT := 'Image Shown'
Add_Entry To_List(#List1)
#ColumnImage1.CurrentItem.image <= #VB_ARROWF
Endif
The logic of list entry update in GotSelection EVTROUTINE is fully corect.
- Stewart Marshall
- Posts: 417
- Joined: Thu Nov 05, 2015 5:25 pm
Re: updating a list entry image column
Thanks Jiri
Re: updating a list entry image column
Thank you. I got it to work (once I actually had the image on the server
)
