c# - Different Kendo grid Datasource when grouping applied -
i have kendo grid, following decleration:
@(html.kendo().grid<agencyautomation.domainlayer.viewmodels.invoicedetailviewmodel>() .name("invoicedetailgrid") .bindto((ienumerable<agencyautomation.domainlayer.viewmodels.invoicedetailviewmodel>)@viewbag.invoicedetails) .columns(columns => { // columns.bound(p => p.accountid).hidden(); columns.bound(p => p.stakeholderid).hidden(); columns.bound(p => p.commissiontypeid).hidden(); columns.bound(p => p.billdescription).hidden(); columns.bound(p => p.groupno).hidden().clientgroupheadertemplate("<span style='float:right'><button id='btngroupedit' onclick='showgroupedit(#=value#)' class='btn btn-primary round_blue'><i class='fa fa-edit'></i> edit</button></span>"); columns.bound(p => p.stakeholderdesc).filterable(true).sortable(true).title("stakeholder").groupable(true); columns.bound(p => p.stakeholdername).filterable(true).sortable(true).title("stakeholder name"); columns.bound(p => p.amounttype).filterable(true).sortable(true).title("amount type"); columns.bound(p => p.commissiontypedescription).filterable(true).sortable(true).title("commission type"); columns.bound(p => p.commissionvalue).filterable(true).sortable(true).title("commission value").clienttemplate("#if (commissionvalue > 0){#<div>#=commissionvalue#</div>#} else {#<div></div>#}#"); columns.bound(p => p.plancode).filterable(true).sortable(true).title("plan code"); columns.bound(p => p.amount).filterable(true).sortable(true).title("amount").format("{0:c2}").clientfootertemplate("").clientgroupfootertemplate("<div> $#=sum#</div>").format("{0:c2}"); columns.bound(p => p.groupno).hidden(); // columns.bound(p => p.invoicedetailid).clienttemplate(gridrowicons).title("").filterable(false).width(90); }) .pageable(pageable => pageable.buttoncount(5).pagesizes(true)) .filterable() .selectable(selectable => selectable .mode(gridselectionmode.single)) .navigatable() .groupable(p => p.enabled(false)) .datasource(datasource => datasource .ajax() .aggregates(aggregates => { aggregates.add(p => p.amount).sum(); }) .group(groups => groups.add(p => p.groupno)) .model(model => { model.id(p => p.invoicedetailid); })) .sortable() .filterable() )
based on grouping, based on 'groupno', want modify particular section on popup, remove existing rows group , replace new lineitems. without grouping applied, can access datasource ease , manipulate data. when access grid grouping applied, datasource length returns number of groups available member property containing field on grouping applied.
i tried removing grouping following command: grid.datasource.group([])
or grid.datasource.group("")
not change datasource.
any advice? i'm little oblivious dealing grouping on kendo grid , apparently seems hard nut crack
i ran same problem , figured out solution works me. hope helps someone. ended enumerating groups , pushing items array ends looking ungrouped data.
var grid = $("#gridadminconfig").data("kendogrid"); var groupeddata = grid.datasource.data(); var data = []; //enumerate groups , grab actual items (var = 0; < groupeddata.length; i++) { (var j = 0; j < groupeddata[i].items.length; j++) { data.push(groupeddata[i].items[j]); } }