How to reset/clear dropdown component in UI Builder using client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 05:13 AM - edited 01-17-2023 05:21 AM
Hi,
I working on the UI builder and I want to reset the dropdown component from selected value to the default unselected.
How to achieve that resetting dropdown or clear using client script?
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2023 11:22 PM
Hi,
This is how you can do it.
1. Create a state parameter. For example- "selectedItems" of JSON type and set the value to [].
2. Bind the "Selected Items" property of your dropdown component to this state parameter.
3. Create a client script to set the state parameter.
4. Trigger your client script from any event and the value would reset. Thats it!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2023 02:15 AM
Hi @JagjeetSingh ,
Using setState does not resetting the dropdown component, the selected items remains display. I need to clear the selected items in dropdown.
Is there any way to emit event to clear selected items? or any other options will helpful.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2023 01:46 AM
did you follow each step. I did this in my PDI and it works.
Make sure your state parameter is of JSON type and you have to bind it with the component properties.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 04:03 AM
I have followed all steps as you mentioned and using state variable as JSON.
But not able to clear selected items in the dropdown, component keep showing the selected items.