Dynamically set the visiblility of #PRIM_MD.ListIcon

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
gstenstrom
Posts: 17
Joined: Thu Feb 16, 2017 8:35 am

Dynamically set the visiblility of #PRIM_MD.ListIcon

Post by gstenstrom » Tue Dec 18, 2018 8:12 am

I need to dynamically set the Visible property on the #PRIM_MD.ListIcon if the list is being view on a mobile device

Here is the list.

Code: Select all

Define_Com Class(#PRIM_MD.List) Name(#List) Displayposition(2) Layoutmanager(#LayoutList) Left(0) Parent(#COM_OWNER) Rowheight(89) Tabposition(1) Top(0) Itemsperrow(5) Height(449) Width(633)
Define_Com Class(#PRIM_MD.ListLabel) Name(#ListFS02_Name) Caption('Name') Displayposition(1) Height(20) Parent(#List) Tabposition(1) Width(106) Source(#FS02_Name) Top(5)
Define_Com Class(#PRIM_MD.ListLabel) Name(#ListFS02_Class) Caption('Class') Displayposition(4) Height(20) Parent(#List) Tabposition(3) Top(25) Width(106) Source(#FS02_Class) Themedrawstyle('ForegroundSecondary')
Define_Com Class(#PRIM_MD.ListLabel) Name(#ListFS02_Subclass) Caption('Sub-Class') Displayposition(5) Height(20) Parent(#List) Tabposition(4) Top(45) Width(106) Source(#FS02_Subclass) Themedrawstyle('ForegroundSecondary')
Define_Com Class(#PRIM_MD.ListLabel) Name(#ListFS02_PhoneNbr1) Caption('Phone') Displayposition(6) Height(20) Parent(#List) Tabposition(5) Top(65) Width(106) Source(#FS02_PhoneNbr1) Themedrawstyle('ForegroundSecondary')
Define_Com Class(#PRIM_MD.ListIcon) Name(#PhoneIcon) Displayposition(2) Icon('phone') Parent(#List) Tabposition(8) Left(68) Top(20)
Here is the code I'm trying to execute without success. On my log. all I'm getting is TREEITEM which makes no sense.
What changes do I need to make to set the visibility of the #PRIM_MD.ListIcon

Code: Select all

For Each(#Item) In(#List.Items)
#SYS_WEB.Console.Log( ('Prepare: ' + #Item.Name.UpperCase) )
#SYS_WEB.Console.Log( ('Prepare: ' + #Item.ComponentClassName) )
#SYS_WEB.Console.Log( ('Prepare Mobile: ' + #Sys_Web.Device) )

If Cond(#Item.Name.UpperCase = ('PhoneIcon').UpperCase)
If Cond(#Sys_Web.Device *EQ Mobile)
#Item.Visible := True
Else
#Item.Visible := False
Endif
Endif
Endfor

BrendanB
Posts: 25
Joined: Tue Nov 24, 2015 10:29 am

Re: Dynamically set the visiblility of #PRIM_MD.ListIcon

Post by BrendanB » Tue Dec 18, 2018 8:49 am

Try:

Code: Select all

For Each(#Item) In(#List.Items)

#PhoneIcon.CurrentItem.Visible := (#Sys_Web.Device = Mobile)

EndFor
This works because:
a. the #Name.CurrentItem points at the named item in the list for the Current Item (in this case also represented by #Item).
b. Using an expression to set the value.

HTH, Brendan.

gstenstrom
Posts: 17
Joined: Thu Feb 16, 2017 8:35 am

Re: Dynamically set the visiblility of #PRIM_MD.ListIcon

Post by gstenstrom » Wed Dec 19, 2018 3:36 am

That didn't work for me. Had to include the Get_Entry command

Code: Select all

* go through the list and make Phone Icon Visible if a mobile device.
For Each(#Item) In(#List.Items)
Get_Entry Number(#Item.Entry) From_List(#List)
#PhoneIcon.CurrentItem.Visible := (#Sys_Web.Device = Mobile)
Endfor

Pablo
Posts: 41
Joined: Wed Dec 02, 2015 10:35 am

Re: Dynamically set the visiblility of #PRIM_MD.ListIcon

Post by Pablo » Wed Dec 19, 2018 5:17 am

Selectlist should work too:

Code: Select all

selectlist #list
#PhoneIcon.CurrentItem.Visible := (#Sys_Web.Device = Mobile)
endselect

Post Reply