Page 1 of 1

Dynamically set the visiblility of #PRIM_MD.ListIcon

Posted: Tue Dec 18, 2018 8:12 am
by gstenstrom
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

Re: Dynamically set the visiblility of #PRIM_MD.ListIcon

Posted: Tue Dec 18, 2018 8:49 am
by BrendanB
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.

Re: Dynamically set the visiblility of #PRIM_MD.ListIcon

Posted: Wed Dec 19, 2018 3:36 am
by gstenstrom
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

Re: Dynamically set the visiblility of #PRIM_MD.ListIcon

Posted: Wed Dec 19, 2018 5:17 am
by Pablo
Selectlist should work too:

Code: Select all

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