Hi Pablo,
Greetings from Syncfusion support.
Yes, we can achieve this requirement using the gridObj.groupMoudle. expandCollapseRows() method in Grid.
In the below code example, we have collapse some groups based on group key values (“Berlin, Madrid”) in an external button click event.
[Index.cshtml]
<ejs-button id="collapseGroup" content="Collapse_Grouped_Rows"></ejs-button>
<ejs-grid id="Grid" dataSource="ViewBag.datasource" allowGrouping="true">
<e-grid-groupsettings columns="@(new string[] { "ShipCity" })" showGroupedColumn="true"></e-grid-groupsettings>
<e-grid-columns>
...
</e-grid-columns>
</ejs-grid>
</div>
</div>
<script>
document.getElementById('collapseGroup').addEventListener('click', function (args) {
var obj = document.getElementById('Grid').ej2_instances[0];
var collapsableKeyValue = ["Berlin", "Madrid"];
for (var i = 0; i < collapsableKeyValue.length; i++ ) {
var collapseElement = obj.getContentTable().querySelectorAll("td[ej-mappingvalue= '" + collapsableKeyValue[i] + "']")[0];
obj.groupModule.expandCollapseRows(collapseElement);
}
});
</script>
|
We have prepared a sample and it can be downloadable from the below location.
Regards,
Thavasianand S.