Hello. I have a grouped grid that i want custom group headers for.
Today, i do it by taking the tree root element, iterating through all childrens, checking the "isGroupSummary" and updating accordingly. This is the code:
I have a simple question: With many rows this might take some time. It also feels kind of "hacky". Is there a quicker way to get the group header nodes? Perhaps using the "getFolders" method i found in the Tree class? Or something else?
Pointers much appreciated.
Today, i do it by taking the tree root element, iterating through all childrens, checking the "isGroupSummary" and updating accordingly. This is the code:
Code:
@Override
public void updateHeadersForGroupedGrid(ListGrid groupedGrid) {
Tree tree = groupedGrid.getGroupTree();
if (tree == null) {
return;
}
for (TreeNode treeNode : tree.getChildren(tree.getRoot())) {
String sum = findGroupSummaryField(tree, treeNode, groupSummaryNameColumn);
if (sum != null) {
treeNode.setAttribute("singleCellValue", treeNode.getAttribute("groupValue") + ": " + formatter.format(sum, treeNode, 1, 1) + " " + unitName);
} else {
treeNode.setAttribute("singleCellValue", treeNode.getAttribute("groupValue"));
}
}
groupedGrid.markForRedraw();
}Pointers much appreciated.