<div>
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.datasource)...ActionBegin("ActionBegin").ActionComplete("ActionComplete")...Render()
</div>
<script type="text/javascript">
var collapsedGroupindex = [];
function ActionBegin(args) {
if (args.requestType == "delete" || (args.requestType == "save" && args.action == "add")) { //Check for this condition to make action perform only during delete and add
var collapsedrows = document.getElementsByClassName("e-recordpluscollapse");
for (var i = 0; i < collapsedrows.length; i++) {
collapsedGroupindex.push(document.getElementsByClassName("e-recordpluscollapse")[i].getAttribute("ej-mappingvalue")); //push the mapping value of the collapsed rows in a variable.
}
}
}
function ActionComplete(args) {
if (args.requestType == "delete" || (args.requestType == "save" && args.action == "add")) { //Check for this condition to make action perform only during delete and add
setTimeout(function () {
var gridObj = document.getElementById("Grid").ej2_instances[0]; //Get Instance for Grid
for (var i = 0; i < collapsedGroupindex.length; i++) {
gridObj.groupModule.expandCollapseRows(document.querySelectorAll("td[ej-mappingvalue='" + collapsedGroupindex[i] + "']")[0]); //Call the “expandCollapseRows” with the corresponding row index td(selected based on mapping value) element.
}
collapsedGroupindex = [];
}.bind(collapsedGroupindex), 1);
}
}
</script>
|