how to get selected value for Kendo DropDownList -
i can't figure out how determine item selected in kendo dropdownlist. view defines it's model as:
@model kendoapp.models.selectorviewmodel
the viewmodel defined as:
public class selectorviewmodel { //i want set selected item in view //and use set initial item in dropdownlist public int encselected { get; set; } //contains list if items dropdownlist //selectiontypes contains id , description public ienumerable<selectiontypes> enctypes }
and in view have:
@(html.kendo().dropdownlist() .name("encountertypes") .datatextfield("description") .datavaluefield("id") .bindto(model.enctypes) .selectedindex(model.encselected) )
this dropdownlist contains values expect need pass selected value controller when user clicks submit button. works fine except don't have access item selected controller's [httppost] action. so, how assign dropdownlist's value hidden form field available controller?
maybe should using dropdownlistfor construct of kendo dropdownlist in view:
@(html.kendo().dropdownlistfor(m => m.encselected) .name("encountertypes") .datatextfield("description") .datavaluefield("id") .bindto(model.enctypes) .selectedindex(model.encselected) )
this way, when submit, availble on post request , won't need put hidden field anywhere.
but should need use hidden field reason, put there, subscribe the select event of dropdown list , put using jquery (for instance) put selected item on hidden field.
it's choice :)
Comments
Post a Comment