Kendo DataSource create method not getting called -
why transport's create method not being called when click "save changes" button on grid? appears working except controller code create isn't getting called.
kendo code:
var ds = new kendo.data.datasource({ transport: { read: { cached: false, url: '@url.action("getlistoffacilities", "tactic")', datatype: "json" } } }); var orgdatasource = new kendo.data.datasource({ transport: { read: { url: '@url.action("readorganizations", "tactic")', datatype: "json" }, create: { url: '@url.action("addorganization", "tactic")', type: "post", datatype: "json" } }, batch: false schema: { model: { id: "id", fields: { id: { type: "string", editable: false }, name: { type: "string" } } } } }); $("#facilitygrid").kendogrid({ datasource: orgdatasource, autobind: true, autosync: true, editable: { mode: "inline" }, selectable: true, toolbar: ["save", "create"], columns: [ { command: ["destroy"], title: " ", width: "150px" }, { field: "name", title: "facility name", editor: orgdropdowneditor }, ] }); function orgdropdowneditor (container, options) { $('<input required data-text-field="text" data-value-field="value" data-bind="value:' + options.field + '"/>') .appendto(container) .kendodropdownlist({ autobind: true, datasource: ds }); }
controller code:
[httppost] public jsonresult addorganization(selectlistitem selectedorg) { ... } [httpget] public string getlistoffacilities() { var lst = new list<selectlistitem>(); lst.add(new selectlistitem() { value = "1", text = "facility 1" }); lst.add(new selectlistitem() { value = "2", text = "facility 2" }); lst.add(new selectlistitem() { value = "3", text = "facility 3" }); lst.add(new selectlistitem() { value = "4", text = "facility 4" }); lst.add(new selectlistitem() { value = "5", text = "facility 5" }); var json = new javascriptserializer().serialize(lst); return json; }
try removing "id" fields object. doesn't need in there if have specified id of model.
Comments
Post a Comment