This is a migrated thread and some comments may be shown as answers.

DropDownList loose text property on Open - how to set text prop on close event

4 Answers 7 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Fabio Masini
Top achievements
Rank 1
Fabio Masini asked on 22 Oct 2018, 01:24 PM

Hi I have a Kendo DropDownList with server filtering set with 3 min characters.

It works fine but when I bind the form, I have no data "inside" the control (autobind = false) and I had to set the text property to show the "selected value".

When user click on it to search an item, the control loose the text value.

When the popup close I expect the control show the text value yet, but If user doesn't select an item, the text value is empty.

I've tried to set the text value on close event but It doesn't works.

This is an example (read data property is set to unexists url but for this sample, data are useless)

Example: https://dojo.telerik.com/awuVEdEM/3

to reproduce 1. Run (see the text value) 2. click to open (loose text) 2. then click to close (the function call is correct but no text visible)

I need to persist the text property until user select something else, or to set it on close event.

 

Thank you

4 Answers, 1 is accepted

Sort by
0
Accepted
Veselin Tsvetanov
Telerik team
answered on 24 Oct 2018, 07:14 AM
Hi Fabio,

I would recommend you to use the optionLabel option of the DropDownList widget instead of the text one. The optionLabel will always display text in the DropDownList, when no item from the list has been selected. Here you will find a modified version of the sample sent, applying the above suggestion.

Regards,
Veselin Tsvetanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Fabio Masini
Top achievements
Rank 1
answered on 25 Oct 2018, 02:28 PM

Hi,

I've used optionLabel as you suggest and it works as espected when I have a valid text value.

With a null value, switching from text to optionLabel, I gain an error, but I have resolve it casting an empty string on null value.

For my porpouse this change is a valid solution, just in one case I'd like to use both the property: text to persist the binded value, and optionLabel as info (ex "filter by name").

As I've said, for me is ok, but please consider this for future implementations

Thank you

0
Veselin Tsvetanov
Telerik team
answered on 29 Oct 2018, 09:07 AM
Hi Fabio,

I am not quite sure if I correctly understand the scenario in question. Do you have in mind a case in which the option value is displayed as selected in the DropDownList ("filter by name") and in the same time a valid value is bound to the widget? If this is the case, I am afraid it will lead to inconsistency between the displayed result and the underlying value selection. Therefore, such scenario would remain unsupported by the widget.

If your idea is different in some manner, please explain a bit in detail the case.

Regards,
Veselin Tsvetanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Fabio Masini
Top achievements
Rank 1
answered on 05 Nov 2018, 08:20 AM

yes that was my idea, but I've seen I could set a message inside the header template with info how to set the filter.

Thank you

Tags
DropDownList
Asked by
Fabio Masini
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Fabio Masini
Top achievements
Rank 1
Share this question
or