I need to create new functionality for DropdownSearch or use a different component.
I have an entity that looks like this:
I need to create something like DropdownSearch that works as follows:
When the user searches for a record and the record does not exist, and the user clicks Enter, it should add a new record to the database with the typed name.
Is there any possibility to achieve this?
I can use different component, that looks different, but already have this functionality.
Hello @Łukasz Kaproń
Dropdown Search/Tags already allow you to have that functionality:
For that, you need to use the extensibility client action
SetVirtualSelectConfigs,that should be called in the Initialized event handler from the Dropdown Search/Tags, and where the property allowNewOption should be set to True, like this:
SetVirtualSelectConfigs,
Initialized
allowNewOption
Then, in the InChanged event handler, we need to use JSONSerialize
This way, we can get the values in JSON and work with them for new options:
Hope it helps!
Cheers,GM
In ODC, you can use DropddownServerSide to handle this. Please refer to this sample https://personal-zfpr4idz-dev.outsystems.app/DropdownServerSideDemo/Hope this help
Hi @Lukasz Kapron
I don't think using outsystems default dropdown search component you can achieve this. you need to create custom drop down for this.
Thanks
Hi Lukasz,
There this component in forge that might help you. This uses the widget DropdownServerSide, if you don't want to use that widget you can at least see how to implement that logic into your custom DropdownSearch widget.
Hi @Lukasz Kapron, I would suggest you to use DropdownServerSide, it has customization possibility, in the "BalloonContent" placeholder, in the if condition when the list is empty instead of showing "No options to show..." text, you can add button to add the typed value. This will be faster then building a custom dropdown.
ThanksGitansh Anand
Where can I find it in ODC?
Hi @Lukasz Kapron, check in OutSystemsUI, if its not there then maybe it is not available in ODC yet.
Hi,
you can implement this simple pattern like track the user input using the OnChange event of the DropdownSearch or a separate Input field.
If the entered value is not found in your existing list, show a conditional UI block a button or message like Add X as new item?
On click of that button, trigger an action to create the new value in your entity update the source list and set the newly created value as the selected one.
Refresh the DropdownSearch options.
Thanks,
Sriyamini J
How can I track user input? I don't see any event for this
Hi @Lukasz Kapron,
You can achieve this using the "Dropdown + Input" hybrid approach which would be a in customized way. Since you want the user to type and then press enter to save if the record isn't found, you can use a combination of a Search Input and a List.
You can follow below approach:
Hope this helps.