PRIM_MD.List selected entry

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
kno_dk
Posts: 110
Joined: Tue Feb 23, 2016 12:00 am

PRIM_MD.List selected entry

Post by kno_dk » Thu Nov 28, 2019 1:36 am

Hi.

I have a list where I want to highlight the selected entry. I works fine when i add it to the list. But I am having problems when I select a new entry in the list. I also want the firste one to be unselected. I have done some test but I am a bit lost right now.

Here is my code:

Begin_Com Role(*EXTENDS #PRIM_WEB) Theme(#SYS_THEME<MaterialDesignBlue>) Layoutmanager(#Layout1)


Define_Com Class(#FDKDataObject) Name(#GlobalData) Scope(*APPLICATION)

Define_Com Class(#PRIM_VS.Style) Name(#Style1) Underline(False) Backgroundbrush(#Brush1)
Define_Com Class(#PRIM_VS.SolidBrush) Name(#Brush1) Color(41:182:246)

Define_Com Class(#PRIM_BOLN) Name(#OK)


Define_Com Class(#PRIM_TBLO) Name(#Layout1)
Define_Com Class(#PRIM_TBLO.Row) Name(#Layout1Row1) Displayposition(1) Parent(#Layout1)
Define_Com Class(#PRIM_TBLO.Column) Name(#Layout1Column1) Displayposition(1) Parent(#Layout1)
Define_Com Class(#PRIM_TBLO.Item) Name(#Layout1Item2) Manage(#Panel) Parent(#Layout1) Row(#Layout1Row1) Column(#Layout1Column1) Alignment(TopLeft) Flow(Down)


Define_Com Class(#PRIM_TBLO) Name(#Layout)
Define_Com Class(#PRIM_TBLO.Column) Name(#LayoutColumn1) Displayposition(1) Parent(#Layout)
Define_Com Class(#PRIM_TBLO.Row) Name(#LayoutRow1) Displayposition(1) Parent(#Layout)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem1) Manage(#List) Parent(#Layout) Row(#LayoutRow1) Column(#LayoutColumn1) Alignment(TopLeft) Flow(Down)

Define_Com Class(#PRIM_TBLO) Name(#LayoutList)
Define_Com Class(#PRIM_TBLO.Column) Name(#LayoutListColumn1) Displayposition(1) Parent(#LayoutList)
Define_Com Class(#PRIM_TBLO.Row) Name(#LayoutListRow1) Displayposition(1) Parent(#LayoutList)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutListItem1) Alignment(CenterLeft) Column(#LayoutListColumn1) Manage(#ListIcon) Marginleft(8) Parent(#LayoutList) Row(#LayoutListRow1) Sizing(None)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutListItem2) Alignment(CenterLeft) Column(#LayoutListColumn1) Manage(#ListPrimaryText) Marginleft(68) Marginright(16) Parent(#LayoutList) Row(#LayoutListRow1) Sizing(ContentHeightFitToWidth)

Define_Com Class(#PRIM_PANL) Name(#Panel) Displayposition(1) Height(800) Left(0) Parent(#COM_OWNER) Tabposition(1) Tabstop(False) Top(0) Width(1200) Layoutmanager(#Layout)
Define_Com Class(#PRIM_MD.List) Name(#List) Displayposition(1) Layoutmanager(#LayoutList) Left(0) Parent(#Panel) Rowheight(35) Tabposition(1) Themedrawstyle('Card') Top(0) Height(800) Width(1200)
Define_Com Class(#PRIM_MD.ListIcon) Name(#ListIcon) Displayposition(1) Height(32) Icon('play_arrow') Iconimagesizing(Cropped) Left(8) Parent(#List) Tabposition(1) Themedrawstyle('ForegroundMediumPrimary') Top(1) Width(32)
Define_Com Class(#PRIM_MD.ListLabel) Name(#ListPrimaryText) Caption('Single line item') Displayposition(3) Height(20) Left(68) Parent(#List) Tabposition(3) Top(7) Width(1114)

Evtroutine Handling(#Com_owner.Initialize)
#COM_OWNER.Get_man
Endroutine
Mthroutine Name(Get_man)
Clr_List Named(#List)
Execute Subroutine(manufacturers) With_Parms(000002 "ALFA ROMEO")
Execute Subroutine(manufacturers) With_Parms(000881 "ASTON MARTIN")
Execute Subroutine(manufacturers) With_Parms(000005 "AUDI")
Execute Subroutine(manufacturers) With_Parms(000815 "BENTLEY")
Execute Subroutine(manufacturers) With_Parms(000016 "BMW")
Execute Subroutine(manufacturers) With_Parms(000816 "BUICK")
Execute Subroutine(manufacturers) With_Parms(000819 "CADILLAC")
Execute Subroutine(manufacturers) With_Parms(000138 "CHEVROLET")
Execute Subroutine(manufacturers) With_Parms(000020 "CHRYSLER")
Execute Subroutine(manufacturers) With_Parms(000021 "CITROËN")
Execute Subroutine(manufacturers) With_Parms(000139 "DACIA")
Execute Subroutine(manufacturers) With_Parms(000185 "DAEWOO")
Execute Subroutine(manufacturers) With_Parms(000025 "DAIHATSU")
Execute Subroutine(manufacturers) With_Parms(000029 "DODGE")
Execute Subroutine(manufacturers) With_Parms(000700 "FERRARI")
Execute Subroutine(manufacturers) With_Parms(000035 "FIAT")
Execute Subroutine(manufacturers) With_Parms(000036 "FORD")
Execute Subroutine(manufacturers) With_Parms(000776 "FORD USA")
Execute Subroutine(manufacturers) With_Parms(000045 "HONDA")
Execute Subroutine(manufacturers) With_Parms(000183 "HYUNDAI")
Execute Subroutine(manufacturers) With_Parms(000054 "ISUZU")
Execute Subroutine(manufacturers) With_Parms(000056 "JAGUAR")
Execute Subroutine(manufacturers) With_Parms(000882 "JEEP")
Execute Subroutine(manufacturers) With_Parms(000184 "KIA")
Execute Subroutine(manufacturers) With_Parms(000063 "LADA")
Execute Subroutine(manufacturers) With_Parms(000701 "LAMBORGHINI")
Execute Subroutine(manufacturers) With_Parms(000064 "LANCIA")
Execute Subroutine(manufacturers) With_Parms(001820 "LAND ROVER")
Execute Subroutine(manufacturers) With_Parms(000842 "LEXUS")
Execute Subroutine(manufacturers) With_Parms(000802 "LOTUS")
Execute Subroutine(manufacturers) With_Parms(000771 "MASERATI")
Execute Subroutine(manufacturers) With_Parms(000072 "MAZDA")
Execute Subroutine(manufacturers) With_Parms(000074 "MERCEDES-BENZ")
Execute Subroutine(manufacturers) With_Parms(000075 "MG")
Execute Subroutine(manufacturers) With_Parms(001523 "MINI")
Execute Subroutine(manufacturers) With_Parms(000077 "MITSUBISHI")
Execute Subroutine(manufacturers) With_Parms(000080 "NISSAN")
Execute Subroutine(manufacturers) With_Parms(000084 "OPEL")
Execute Subroutine(manufacturers) With_Parms(000088 "PEUGEOT")
Execute Subroutine(manufacturers) With_Parms(000774 "PONTIAC")
Execute Subroutine(manufacturers) With_Parms(000092 "PORSCHE")
Execute Subroutine(manufacturers) With_Parms(000093 "RENAULT")
Execute Subroutine(manufacturers) With_Parms(000705 "ROLLS-ROYCE")
Execute Subroutine(manufacturers) With_Parms(000095 "ROVER")
Execute Subroutine(manufacturers) With_Parms(000099 "SAAB")
Execute Subroutine(manufacturers) With_Parms(000104 "SEAT")
Execute Subroutine(manufacturers) With_Parms(000106 "SKODA")
Execute Subroutine(manufacturers) With_Parms(001138 "SMART")
Execute Subroutine(manufacturers) With_Parms(000175 "SSANGYONG")
Execute Subroutine(manufacturers) With_Parms(000107 "SUBARU")
Execute Subroutine(manufacturers) With_Parms(000109 "SUZUKI")
Execute Subroutine(manufacturers) With_Parms(003328 "TESLA")
Execute Subroutine(manufacturers) With_Parms(000111 "TOYOTA")
Execute Subroutine(manufacturers) With_Parms(000120 "VOLVO")
Execute Subroutine(manufacturers) With_Parms(000121 "VW")
Endroutine

Subroutine Name(manufacturers) Parms(#KHERNR #WWWWMERKE)

* Invoke the server module
* Display the result (if OK), or error message (if failed)

#ListPrimaryText := #WWWWMERKE + '(' + #KHERNR.asstring + ')'
If Cond(#KHERNR = 121)
#List.CurrentItem.Selected #List.CurrentItem.Focus := True
#ListIcon.Visible := True
#ListPrimaryText.ThemeDrawStyle := Heading3+MediumTitle
Else
#ListIcon.Visible := False
#ListPrimaryText.ThemeDrawStyle := ' '
Endif
Add_Entry To_List(#List)


Endroutine
* Evtroutine Handling(#List.ItemGotSelection) Item(#item)
* #ListIcon.Visible := True
* #ListPrimaryText.ThemeDrawStyle := Heading3+MediumTitle

* Endroutine
Evtroutine Handling(#List.ItemLostSelection) Item(#item)
#ListIcon.Visible := False
#ListPrimaryText.ThemeDrawStyle := ' '

Endroutine
Evtroutine Handling(#ListPrimaryText.Click)
#ListIcon.Visible := True
#ListPrimaryText.ThemeDrawStyle := Heading3+MediumTitle


Endroutine
Evtroutine Handling(#list.ItemClick)

#ListIcon.Visible := True
#ListPrimaryText.ThemeDrawStyle := Heading3+MediumTitle
#WWWWMERKE := #ListPrimaryText

Endroutine
End_Com

JamesDuignan
Posts: 66
Joined: Thu Nov 26, 2015 1:43 pm

Re: PRIM_MD.List selected entry

Post by JamesDuignan » Mon Dec 02, 2019 10:31 am

Hi,

You need to have the currentitem property included in your setting and removing of the styles. This will ensure that the selection lost will remove the style from the appropriate entry and item click will add it to the newly selected one

for example

Code: Select all

Evtroutine Handling(#List.ItemLostSelection) 

#ListIcon.[b]CurrentItem[/b].Visible := False
#ListPrimaryText.[b]CurrentItem[/b].ThemeDrawStyle := ' '

Endroutine

Evtroutine Handling(#list.ItemClick)

#ListIcon.[b]CurrentItem[/b].Visible := True
#ListPrimaryText.[b]CurrentItem[/b].ThemeDrawStyle := Heading3+MediumTitle
#XDEMOAL_1 := #ListPrimaryText

Endroutine
Regard,
James Duignan

Post Reply