Retractable ListBox with multiple values

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
mgardes
New User
Posts: 9
Joined: Thu Nov 22, 2018 10:56 am
First Name: Maximilien
Last Name: G.
Company Name: SERMES
City: Strasbourg
Country: France
Contact:

Retractable ListBox with multiple values

Post by mgardes »

Hello,

I need to display a ListBox with multiple values but i can't put a big ListBox on my screen.
I would like the same display that a ListBox with one value but with the possibility to select multiple values.

Is it possible to make this without write our own widget ?

Thanks
User avatar
Megan
Profound Logic Staff Member
Posts: 90
Joined: Mon Sep 11, 2017 12:15 pm
First Name: Megan
Last Name: Bond
Company Name: Profound Logic
Phone: 5623227473
State / Province: California
Zip / Postal Code: 92692
Country: United States
Contact:

Re: Retractable ListBox with multiple values

Post by Megan »

Hello Maximilien,

There are a variety of ways to approach solving this issue. One way would to add an onclick event that will use the applyProperty() Profound UI API to change the number of options displayed by changing the height or the select box height properties. In the following example, I use applyProperty() to change the height of the select box. You can check out the result here: https://noderun.com/run/megan_bond/sett ... lt-values/. You can check out the code here: https://noderun.com/ide/megan_bond/sett ... lt-values/.

onblur event and ondblclick event, reset height of listbox:

Code: Select all

applyProperty(this, "height", "65px");
onclick event, expand height of listbox:

Code: Select all

applyProperty(this, "height", "calc(100% - 30px)");
You may notice in the onclick event that I used "calc(100% - 30px)" for the height value. This is because the listbox is placed 15px from the top and I want it to end 15px before the end of its container element.The keyword 'this' refers to the element that triggered the event and is provided to the event for you.

The code above will expand and contract the listbox but it won't animate the transition. It will simply switch from one size to the other instantly. To animate the transition, CSS can be used to have the browser handle it. Below is the CSS class I used to animate the listbox height change.

Code: Select all

.pui-height-transition {
  
  -webkit-transition: width 2s, height 4s; /* For Safari 3.1 to 6.0 */
  transition: width 2s, height 4s;

}
CSS would be added to an outside file and either linked or, if put in the custom folder of a Profound UI or PJS instance, it will be pulled in automatically. Because noderun doesn't have this, I used the external css property to link ~/workspace/public/styles/styles.css.

The properties:
listbox.png
listbox.png (15.09 KiB) Viewed 457 times
The result:
listbox.gif
listbox.gif (116.86 KiB) Viewed 457 times
I hope this helps!

Thanks,
~MEGAN BOND
Technical Support Specialist
support@profoundlogic.com
k2R400
Profound User
Posts: 62
Joined: Sat Feb 18, 2012 12:03 pm
First Name: Patrick
Last Name: THOMAS
Company Name: Oo2
Country: France
Contact:

Re: Retractable ListBox with multiple values

Post by k2R400 »

Very interesting answer, I put in my tips and tricks !
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests