标签云

微信群

扫码加入我们

WeChat QR Code

Why is my transport's create method not being called when I click the "Save Changes" button on the grid? Everything appears to be working except my controller code for 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: falseschema: {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: "&nbsp;", 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;}


if I set OrgdataSource'sid field to editable, my controller code gets called. But I can't allow that field to be edited.

2019年04月19日59分10秒

Thanks for your reply but that still didn't fix the problem.

2019年04月20日59分10秒

Just noticed you have autosync set to true.That will automatically try and save records back to the dataSource.I think it also disables the manual saving functionality.If you want your users to click a button to save you should set this to false.

2019年04月20日59分10秒

This is how i have been setting up grids when using js and not MVVM bindings:$("#scheduleEquipmentXSGrid").kendoGrid({dataSource: viewModel.equipmentXSDataSource,editable: true,toolbar: ['create'],editable: { mode: 'popup', template: kendo.template($("#eqPopTemplate").html()) }, columns: []

2019年04月20日59分10秒