Hello,
We have a grid with a default grouping applied to it, and are trying to persist the expanded groups through a read operation (remote datasource).
We have been successful in persisting them through some operations using the following code:
function getExpandedGroups() {
expandedGroups = [];
try {
let groupRows = $(".k-grouping-row");
for (let i = 0; i < groupRows.length; i++) {
let e = groupRows[i];
let expanded = e.children[0]["ariaExpanded"];
if (expanded === "true") {
let groupName = $(e).find(".k-reset").text();
let slicePos = groupName.lastIndexOf(" (");
groupName = groupName.slice(0, slicePos);
expandedGroups.push(groupName);
}
}
}
catch { }
return expandedGroups;
}
function restoreExpandedGroups() {
try {
groupRows = $(".k-grouping-row");
for (let i = 0; i < groupRows.length; i++) {
let e = groupRows[i];
let groupName = $(e).find(".k-reset").text();
let slicePos = groupName.lastIndexOf(" (");
groupName = groupName.slice(0, slicePos);
if (expandedGroups.includes(groupName)) {
attachmentTable.expandGroup(e);
}
}
}
catch { }
}
which works fine if our code calls the read event, since we can execute it before and after eg.
let expandedGroups = getExpandedGroups();
attachmentTable.dataSource.read().then(function () {
restoreExpandedGroups(expandedGroups);
});
however, when we use any of the grid functionality like sorting on a column, there doesn't seem to be any events that we can subscribe to that occur after the grid sets the groups back to their collapsed state, and we aren't able to persist the grouping in the same way.
Are there any potential workarounds for this issue?
Thanks
Regards,
Will Douglas