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

Dropdownlist in grid popup not javascript binding

2 Answers 264 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Adam King
Top achievements
Rank 1
Adam King asked on 05 Apr 2019, 08:35 PM

Our dropdownlist is in a popup editor of a kendogrid.

It has a databound event where we conditionally select the 1st item.

.Events(events => events.DataBound("function() { if (this.value() == '' && this.dataSource.data().length == 1) { this.select(1); } }"))

This works to change the dropdown (and it's hidden input), but when we post back the value is zero. 

If we manually select the 1st item then it binds and posts back correctly.

A similar databound event works on other screens, but it just seems to be only a problem the built-in popup editor of the kendo grid.

Any ideas how to get the .select to update the dataItem & post back correctly?

2 Answers, 1 is accepted

Sort by
0
Adam King
Top achievements
Rank 1
answered on 05 Apr 2019, 08:40 PM

It worked to bind properly once we manually triggered the change event, after the select logic.

this.trigger('change');

0
Dimitar
Telerik team
answered on 09 Apr 2019, 01:33 PM
Hello Adam King,

The Grid uses a model binder internally for the popup. In such scenarios, the select() method will not automatically update the model. As you have correctly observed, the issue is resolved by manually triggering the change event. Additional information regarding this behavior is available in the API reference:


Regards,
Dimitar
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.
Tags
DropDownList
Asked by
Adam King
Top achievements
Rank 1
Answers by
Adam King
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or