asp.net mvc - Make editable Kendo grid in partial view in MVC -
i want make editable kendo grid partial view control use many times when needed.
i have customer , employee have multi address want make editable kendo grid addresses in partial view use in employee , customer.
my partial view kendo grid
@model addressesmodel @using kendo.mvc.ui @{ var prefix = viewdata.templateinfo.htmlfieldprefix; var propertyprefixname = ""; if (string.isnullorempty(prefix)) { propertyprefixname = nameof(addressesmodel.addresseslist); } else { propertyprefixname = prefix + "." + nameof(addressesmodel.addresseslist); } var cityid = nameof(addressmodel.cityid); var email = nameof(addressmodel.email); } @(html.kendo().grid(model.addresseslist) .name("addressgrid") .toolbar(tools => tools.create().text(globalresources.add)) .editable(editable => editable.mode(grideditmode.incell).createat(gridinsertrowposition.bottom)) .columns(columns => { columns.bound(p => p.cityid).clienttemplate("#= " + cityid + " #" + "<input type='hidden' name='" + propertyprefixname + "[#= index(data)#]." + cityid + "' value='#= " + cityid + " #' />" ); columns.bound(p => p.email).clienttemplate("#= " + email + " #" + "<input type='hidden' name='" + propertyprefixname + "[#= index(data)#]." + email + "' value='#= " + email + " #' />" ); columns.command(command => command.destroy()).width(20).title(globalresources.delete); }) .datasource(datasource => datasource.ajax() .model(model => { model.id(p => p.id); model.field(p => p.id).editable(false); }) .serveroperation(false) ) ) <script> function index(dataitem) { var data = $("#addressgrid").data("kendogrid").datasource.data(); return data.indexof(dataitem); } </script>
and in employee view used this
@html.partial("_addressesgrid", model.addresses, new viewdatadictionary { templateinfo = new system.web.mvc.templateinfo { htmlfieldprefix =nameof(createemployeemodel.addresses)} })
and not edited!
please , how can make editable kendo grid in partial view!!
note kendo grid works correctly if put in employee view without partial view.
change
@html.partial("_addressesgrid", model.addresses, new viewdatadictionary { templateinfo = new system.web.mvc.templateinfo { htmlfieldprefix =nameof(createemployeemodel.addresses)} })
to
@html.partial("_addressesgrid", model.addresses)
and careful don't use htmlfieldprefix , kendo make editor cell template error name , have above error
Comments
Post a Comment