javascript - Value is not binding in kendoui dropdown -
i using kendoui dropdownlist. loading values in dropdownlist dynamically. have written code like
$("#dropdown").kendodropdownlist({ datasource: { transport: { read: { url: "/projects/dropdown", type: "post", datatype: "json" } }, }, datatextfield: "type", datavaluefield: "type", value: "type2", }); and in controller have defined like:
public actionresult dropdown(int projectid, int controlid) { var values = context.controloptions.where(i => i.id== id).select(i => new { type = i.value }).toarray(); return json(values, jsonrequestbehavior.allowget); } the values contains array: [{type="type1"},{type="type2"}]. how can bind value of "type2" giving value. adding screen shot of value coming.

either define dropdownlist as:
$("#dropdown").kendodropdownlist({ datasource : { transport: { read: { url : "/projects/dropdown", type : "post", datatype: "json" } } }, value: "type2" }); or return data [{"type":"type1"},{"type":"type2"}] , define dropdownlist as:
$("#dropdown").kendodropdownlist({ datasource : { transport: { read: { url : "/projects/dropdown", type : "post", datatype: "json" } } }, datatextfield: "type", datavaluefield: "type", value : "type2" });
Comments
Post a Comment