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

Material Design Dropdown

Post by atostaine »

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: 85
Joined: Thu Nov 26, 2015 1:43 pm

Re: Material Design Dropdown

Post by JamesDuignan »

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

Re: Material Design Dropdown

Post by atostaine »

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

Art
Art Tostaine
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Material Design Dropdown

Post by atostaine »

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: 48
Joined: Wed Dec 02, 2015 10:35 am

Re: Material Design Dropdown

Post by Pablo »

Hi Art,

you set the value property of the dropdown:

#dropdown.value = value

Regards,
Pablo
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Material Design Dropdown

Post by atostaine »

Thank you.
Art Tostaine
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Material Design Dropdown

Post by atostaine »

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: 85
Joined: Thu Nov 26, 2015 1:43 pm

Re: Material Design Dropdown

Post by JamesDuignan »

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

Re: Material Design Dropdown

Post by atostaine »

Thank you James.
Art Tostaine
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Material Design Dropdown

Post by atostaine »

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

Art
Art Tostaine
adale
Posts: 212
Joined: Wed Apr 08, 2020 9:18 pm
Location: Poplarville, MS

Re: Material Design Dropdown

Post by adale »

Simple MD dropdown columns are "value" and "caption" (and a resulting boolean when adding items to the dd list).

Setting the dd value, and using the dd value are fine, but I would like to use the dd list's value "caption" as well.

User selects an item in the drop down, and I want to use the value's "caption" to display in a resulting dialog.

When I try #dropdown.caption, it just gives me the name/description caption of the dropdown component, and not the list value caption.

Is there a means to retrieve the selected dropdown value's caption? Or even the value/caption pair if need be?
Arlyn Dale
Servias LLC
Post Reply