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

ComboBox EditorTemplate not updating model when click to select

1 Answer 205 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shrinand
Top achievements
Rank 1
Shrinand asked on 10 May 2017, 01:14 AM

I have a column with combobox as editor template. If I type name, it'll select the item and update the model when lost focus. But if I mouse click on an item, it will blank the field.

column binding:

columns.Bound(c => c.ServiceCompany).EditorTemplateName("SharedNameComboBox");    

 

template:

<script>
    function onSelect(e) {
        e.sender.value(e.dataItem);
        e.sender.trigger("change");
    }
</script>
 
@(
Html.Kendo().ComboBox()
    .HtmlAttributes(new { data_bind = "value: " + ViewData.TemplateInfo.HtmlFieldPrefix})
    .Name(ViewData.TemplateInfo.HtmlFieldPrefix)
    .Filter(FilterType.StartsWith)
    .Suggest(true)
    .BindTo(ViewData as IEnumerable<string>)
    .Events(e => e.Select("onSelect"))
)

 

How can I update model upon mouse-click?

 

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 12 May 2017, 02:00 PM

Hello,

Are there any errors in the console? Also I noticed that the ComboBox is bound to a list of strings. Given this the value of the widget should be set to the selected string and there should be no need of setting the value of the widget in the select handler. Just in case you can try to set the ValuePrimitive(true) option for the Kendo UI ComboBox for ASP.NET MVC. 

Regards,
Boyan Dimitrov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Shrinand
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or