How can I clear the DropdownSearch selection on the OnSelect Event based on condition
Question
Application Type
Reactive

I can reset it with the click of another button, but I want to do the same with the OnSelect event.

mvp_badge
MVP
Solution

Hi Mayank,

I expect that you are aware that the DropdownSearch widget version that you are using is deprecated in the latest OutSystemsUI version.

 I tried multiple approaches to reset/remove active items in the deprecated DropdownSearch widget, unfortunately, none of them worked.

The only option I see is to clone the DropdownSearch widget to your application Core Widget module and customize it to achieve the reset functionality. And, as this widget is deprecated in the latest OutSystemsUI version, I suppose that there won't be any updates for this widget in the future from the OutSystems end.

In the cloned DropdownSearch widget exposes an event passing the initialized object to the parent scope. Referring to the initialized choices object, you can call the removeActiveItems method to reset the DropdownSearch.

JS Snippet:

setTimeout(function() {
    $parameters.ChoicesObj.removeActiveItems();
}, 1);

Demo screen: ResetDropdownSearchTask

Refer to the attached oml

I hope this helps you!


Kind regards,

Benjith Sam

NeoLab_ResetDropdownSearchTask.oml

mvp_badge
MVP

Hi Mayank,

For the mentioned use case, I have drafted two working approaches in the attached oml, out of which I think the below-mentioned JS solution is the clean solution.

  • In the Dropdown Search widget OnChanged event handler action flow, conditionally execute the below JS to reset the selection.

JS Snippet:

OutSystems.OSUI.Patterns.DropdownAPI.GetDropdownById($parameters.DropdownWidgetId)._virtualselectMethods.reset();

Demo screen: ResetDropdownSearchTask

Refer to the attached oml


I hope this helps you!


Kind regards,

Benjith Sam

NeoLab_ResetDropdownSearchTask.oml

Thanks Sam. The most recent version of OutSystems UI DropdownSearh widget, which contains an OnChanged Event, is compatible with this solution. 

I am working on OutSystems UI Version 2.8.0 where for DropdownSearch widget is showing me only OnSelect Event. Could you help me regarding this one?

mvp_badge
MVP
Solution

Hi Mayank,

I expect that you are aware that the DropdownSearch widget version that you are using is deprecated in the latest OutSystemsUI version.

 I tried multiple approaches to reset/remove active items in the deprecated DropdownSearch widget, unfortunately, none of them worked.

The only option I see is to clone the DropdownSearch widget to your application Core Widget module and customize it to achieve the reset functionality. And, as this widget is deprecated in the latest OutSystemsUI version, I suppose that there won't be any updates for this widget in the future from the OutSystems end.

In the cloned DropdownSearch widget exposes an event passing the initialized object to the parent scope. Referring to the initialized choices object, you can call the removeActiveItems method to reset the DropdownSearch.

JS Snippet:

setTimeout(function() {
    $parameters.ChoicesObj.removeActiveItems();
}, 1);

Demo screen: ResetDropdownSearchTask

Refer to the attached oml

I hope this helps you!


Kind regards,

Benjith Sam

NeoLab_ResetDropdownSearchTask.oml

Benjith, I appreciate you taking your time with this. Without a doubt, this is what I need to do right now.

Yes, I am aware that the DropdownSearch I am using is obsolete in the most recent version, but regrettably we are unable to change the OutSystems UI version at this time.

Once more, I appreciate you guiding me.

mvp_badge
MVP

You're welcome, Mayank.

Glad to help you :)


Kind regards,

Benjith Sam

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.