updating a list entry image column

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
dhnaigles
Posts: 43
Joined: Wed Feb 03, 2016 1:34 am
Location: Marlborough, MA, USA

updating a list entry image column

Post by dhnaigles » Sat Mar 19, 2016 3:29 am

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 122 times

User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: updating a list entry image column

Post by Stewart Marshall » Sat Mar 19, 2016 10:52 am

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
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au

User avatar
Jiri
Posts: 44
Joined: Thu Feb 11, 2016 11:41 pm

Re: updating a list entry image column

Post by Jiri » Thu Mar 31, 2016 3:17 am

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.

User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: updating a list entry image column

Post by Stewart Marshall » Thu Mar 31, 2016 7:50 am

Thanks Jiri
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au

dhnaigles
Posts: 43
Joined: Wed Feb 03, 2016 1:34 am
Location: Marlborough, MA, USA

Re: updating a list entry image column

Post by dhnaigles » Sat Apr 02, 2016 6:37 am

Thank you. I got it to work (once I actually had the image on the server :) )

Post Reply