I'm trying to sort the rows/columns of a cube grid by the values in a facet, where the data is coming from client side data that has been provided to the cube grid via set data.
Here's the code that I'm trying to get the rows sorted by facet value. The grid does not seem to update after the call to setFacets. Is there some other method that I need to call to force the grid to update? I've tried invalidateCache(), markForRedraw(). Thanks for any and all help.
setCanSortFacets(true);
this.addSortByFacetIdHandler(new SortByFacetIdHandler() {
@Override
public void onSortByFacetId(SortByFacetIdEvent event) {
String facetId = event.getFacetId();
CubeGrid cubeGrid = (CubeGrid) event.getSource();
final int sortDirection = event.getSortDirection() ? +1: -1;
Facet facet = cubeGrid.getFacet(facetId);
Log.info("Got facet "+facet);
FacetValue[] facetValues = facet.getValues();
for(FacetValue facetValue: facetValues) {
Log.info("Facet value: "+facetValue.getAttribute("id"));
}
Facet facetToSort = CubeGridView.this.getFacet(facetId);
Arrays.sort(facetValues, new Comparator<FacetValue>() {
@Override
public int compare(FacetValue fv1, FacetValue fv2) {
return sortDirection*fv1.getAttribute("id").compareTo(fv2.getAttribute("id"));
}
});
facetToSort.setValues(facetValues);
Facet[] newFacets = new Facet[columnFacetNames.length + rowFacetNames.length];
int facetIndex = 0;
for(String rowFacetName: rowFacetNames) {
if(rowFacetName.equals(facetId)) {
newFacets[facetIndex] = facetToSort;
} else {
newFacets[facetIndex] = getFacet(rowFacetName);
}
facetIndex++;
}
for(String colFacetName: columnFacetNames) {
if(colFacetName.equals(facetId)) {
newFacets[facetIndex] = facetToSort;
} else {
newFacets[facetIndex] = getFacet(colFacetName);
}
facetIndex++;
}
setFacets(newFacets);
}
});
1. SmartClient Version: v9.1p_2014-11-01/PowerEdition Deployment (built 2014-11-01)
2. Safari 8.0
Here's the code that I'm trying to get the rows sorted by facet value. The grid does not seem to update after the call to setFacets. Is there some other method that I need to call to force the grid to update? I've tried invalidateCache(), markForRedraw(). Thanks for any and all help.
setCanSortFacets(true);
this.addSortByFacetIdHandler(new SortByFacetIdHandler() {
@Override
public void onSortByFacetId(SortByFacetIdEvent event) {
String facetId = event.getFacetId();
CubeGrid cubeGrid = (CubeGrid) event.getSource();
final int sortDirection = event.getSortDirection() ? +1: -1;
Facet facet = cubeGrid.getFacet(facetId);
Log.info("Got facet "+facet);
FacetValue[] facetValues = facet.getValues();
for(FacetValue facetValue: facetValues) {
Log.info("Facet value: "+facetValue.getAttribute("id"));
}
Facet facetToSort = CubeGridView.this.getFacet(facetId);
Arrays.sort(facetValues, new Comparator<FacetValue>() {
@Override
public int compare(FacetValue fv1, FacetValue fv2) {
return sortDirection*fv1.getAttribute("id").compareTo(fv2.getAttribute("id"));
}
});
facetToSort.setValues(facetValues);
Facet[] newFacets = new Facet[columnFacetNames.length + rowFacetNames.length];
int facetIndex = 0;
for(String rowFacetName: rowFacetNames) {
if(rowFacetName.equals(facetId)) {
newFacets[facetIndex] = facetToSort;
} else {
newFacets[facetIndex] = getFacet(rowFacetName);
}
facetIndex++;
}
for(String colFacetName: columnFacetNames) {
if(colFacetName.equals(facetId)) {
newFacets[facetIndex] = facetToSort;
} else {
newFacets[facetIndex] = getFacet(colFacetName);
}
facetIndex++;
}
setFacets(newFacets);
}
});
1. SmartClient Version: v9.1p_2014-11-01/PowerEdition Deployment (built 2014-11-01)
2. Safari 8.0