Material Design Dropdown

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
atostaine
Posts: 395
Joined: Wed Jan 20, 2016 7:38 am

Material Design Dropdown

Post by atostaine » Thu Jul 26, 2018 4:52 am

With the regular controls you would drag a combo box to your panel, then drag fields onto it.

How do you add fields to the material design combo box?
Art Tostaine

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

Re: Material Design Dropdown

Post by JamesDuignan » Thu Jul 26, 2018 8:58 am

Hi Art,

The material design dropdown is not like the other dropdowns available in LANSA. Dropdown does not need to contain a sourcable field.

So adding an Item to the dropdown will look like:

Code: Select all

#DropDown.Items.Add( 'VALUE1'  'This is a caption for Value 1' )
In the example above "VALUE1" is the value assigned to the field and "This is Value 1" is the caption to be displayed in the dropdown for that item.

If the value is what needs to be displayed without a caption, then not adding the caption parameter will display the value in the list.

The current value of the dropdown is accessed simply by referencing the Name of the Dropdown in an assignment.

below is a simple example of using the dropdown, showing everything mentioned above.

Code: Select all

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

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(#ListPrimaryText) Marginleft(16) Marginright(16) Parent(#LayoutList) Row(#LayoutListRow1) Sizing(ContentHeightFitToWidth)

Define_Com Class(#PRIM_MD.Dropdown) Name(#DropDown) Caption('Caption') Displayposition(1) Left(16) Parent(#COM_OWNER) Tabposition(1) Top(16) Width(404)
Define_Com Class(#PRIM_MD.List) Name(#List) Displayposition(2) Layoutmanager(#LayoutList) Left(71) Parent(#COM_OWNER) Rowheight(48) Tabposition(2) Themedrawstyle('Card') Top(171) Width(722)
Define_Com Class(#PRIM_MD.ListLabel) Name(#ListPrimaryText) Caption('Single line item') Displayposition(1) Height(23) Left(16) Parent(#List) Tabposition(1) Themedrawstyle('Heading3') Top(13) Width(688)

Evtroutine Handling(#Com_owner.Initialize)

* Add the dropdown Values
#DropDown.Items.Add( 'A_VALUE' 'This is a caption for A Value' )

#DropDown.Items.Add( 'B_VALUE' 'This is B Value' )

#DropDown.Items.Add( 'C_VALUE' )

#DropDown.Items.Add( 'D_VALUE' 'I am D Value' )

#DropDown.Items.Add( 'E_VALUE' )


* Assign the initial value to the dropdown
#DropDown := 'A_VALUE1'

Endroutine

Evtroutine Handling(#DropDown.Changed)

#ListPrimaryText := #DropDown

Add_Entry To_List(#List)

Endroutine


End_Com

atostaine
Posts: 395
Joined: Wed Jan 20, 2016 7:38 am

Re: Material Design Dropdown

Post by atostaine » Thu Jul 26, 2018 8:59 am

Thank you. After I posted I saw some samples but it still wasn’t clear to me.

Art
Art Tostaine

atostaine
Posts: 395
Joined: Wed Jan 20, 2016 7:38 am

Re: Material Design Dropdown

Post by atostaine » Fri Sep 21, 2018 5:50 am

After the dropdown is loaded, how can I set the item I want to display? I tried this but it doesn't display the item

for each(#item) in(#dropDown.items)
if (#item.value = #pShipper.asString)
#item.Visible := true
leave
endIf
endFor
Art Tostaine

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

Re: Material Design Dropdown

Post by Pablo » Fri Sep 21, 2018 6:02 am

Hi Art,

you set the value property of the dropdown:

#dropdown.value = value

Regards,
Pablo

atostaine
Posts: 395
Joined: Wed Jan 20, 2016 7:38 am

Re: Material Design Dropdown

Post by atostaine » Fri Sep 21, 2018 6:36 am

Thank you.
Art Tostaine

atostaine
Posts: 395
Joined: Wed Jan 20, 2016 7:38 am

Re: Material Design Dropdown

Post by atostaine » Fri Sep 21, 2018 6:52 am

I add the items similar to this:

#dropdown.items.add('51070' 'SHIPPER NAME')

When I set the value of the dropdown to '51070', it shows 51070. I want it to show 'SHIPPER NAME'

Do I have to use the caption to set the value?
Art Tostaine

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

Re: Material Design Dropdown

Post by JamesDuignan » Fri Sep 21, 2018 9:34 am

Hi Art,

This was rectified in EPC142010. Applying this EPC will fix your issue https://www.lansa.com/support/notes/epc/epc142010.htm

Regards,
James

atostaine
Posts: 395
Joined: Wed Jan 20, 2016 7:38 am

Re: Material Design Dropdown

Post by atostaine » Fri Sep 21, 2018 9:44 am

Thank you James.
Art Tostaine

atostaine
Posts: 395
Joined: Wed Jan 20, 2016 7:38 am

Re: Material Design Dropdown

Post by atostaine » Fri Nov 09, 2018 6:34 am

Is there a way to duplicate the dropdown count property from regular Dropdowns in MD Dropdowns?

Art
Art Tostaine

Post Reply