i have ajax form in view. , kendo grid rendered in partialview within view.
@using (ajax.beginform("addtocatalogue", "home", new ajaxoptions { updatetargetid = "cataloguesummary", insertionmode = insertionmode.replace }, new { id = "addtocatalogueform" })) { <input type="submit" class="button radius hide" id="btnadd" value="add catalogue" /> } @html.partial("~/views/home/_cataloguesummary.cshtml", model.catalogueitem) in partial have grid:
@using web.models @model ienumerable
<div class="row"> <div class="panel"> <h5>summary</h5> <div id="divgrid"> @(html.kendo().grid(model) .name("cataloguesummarygrid") .columns(columns => { columns.bound(c => c.name); columns.bound(c => c.length); columns.bound(c => c.description); columns.bound(c => c.ref); }) .sortable() .datasource(datasource => datasource .ajax() .group(groups => groups.add(p => p.type)) .serveroperation(false)) ) </div> </div> </div> so firing update outside partial in main few, calling action:
[httppost] public partialviewresult addtocatalogue() { // current state of catalogue var api = new serverapi<webcatalogue>(); var webcatalogue = api.getrequest("webcatalogue").result; // set ux state var catalogueitems = new list<catalogueitem>(); // begin existing items prior post catalogueitems.addrange(jsonconvert.deserializeobject<list<catalogueitem>>(webcatalogue.data)); // add in dummy item var newitem = new catalogueitem() { type= "single", name = "mark", length = 5, description = "some desc", ref = "ref 1" }; catalogueitems.add(catalogueitem); // apply new ux state webcatalogue , post web api method var newitems = jsonconvert.serializeobject(catalogueitems); webcatalogue.data = newitems; api.postrequest("webcatalogue", webcatalogue); // return refreshed view return this.partialview("_cataloguesummary", catalogueitems); }
funny thing, writing here question start analysing code deeper searching bug (even though analyse before posting here), after posting question realise issue is.
in case missing div id = "cataloguesummary" had updated on ajax form posting.
adding solved issue ha!
Comments
Post a Comment