Get group id based on enum

Hi,

I have a group table that is grouped on a enum field. I want to programmatically expand all but one of the groups. How could I retrieve the groupinfo for a specific enum option? Note that the specific enum option might not be present in the data set.


// Expand everything except the Ok findings
authChecksDs.addCollectionChangeListener(e -> {
    if (e.getOperation().equals(CollectionDatasource.Operation.REFRESH)) {
        authChecksTable.expandAll();
        // Collapse the Ok group - Not sure how to do this...
        authChecksTable.collapse( authChecksDs.getGroupInfo(Result.OK)); // ?????
    }
});

Any suggestions?

Hi,

You can iterate result of GroupDatasource#rootGroups() (and nested groups) and find GroupInfo that have value that equals to Result.OK. Call GroupInfo#getValue() to get value associated with group info.

Thanks Yuri - this helped me solve the issue.

Code that might be helpful to others:


                for (GroupInfo i : findingsDs.rootGroups()) {
                    if (i.getValue() == FindingResult.OK) {
                        findingsTable.collapse(i);
                    }
                }

Note: I do not have nested groups so do not need to parse them as well. For other solutions you might need to walk the subgroups as well.