display data in grid with merged rows for only column one.
original:
merge rows according to the text of first column, same text should merge together.
like this:
Please help me to find best way doing this dynamically and efficiently.
|
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<div>
<ej:Grid ID="FlatGrid" runat="server" AllowCellMerging="true" AllowSorting="True" AllowPaging="True" IsResponsive="true">
.....
<ClientSideEvents MergeCellInfo ="cellmerge" />
</ej:Grid>
</div>
<script>
function cellmerge(args) {
if (args.column.field == "ShipCity" && !$(args.cell).hasClass("e-merged")) {
var rowInx = this.getIndexByRow(args.cell.closest("tr"));
var merInx = rowInx;
var pageSize = this.model.currentViewData.length;
var prevRow = null, nexRow = null;
var data = ej.DataManager(this.model.currentViewData).executeLocal(new ej.Query().where("ShipCity", "equal", args.data["ShipCity"]));
for (var inx = 0; inx < data.length; inx++) {
var currentdata = this.model.currentViewData;
if (currentdata.indexOf(data[inx]) == merInx)
continue;
else if (merInx + 1 == currentdata.indexOf(data[inx]))
merInx++;
else break;
}
if (rowInx != merInx)
args.rowMerge(merInx - rowInx + 1);
}
}
</script>
</asp:Content> |