View Full Version : How to save last group field (GroupingView) after refresh browser page?

Vadim Kolesnikov
2 Feb 2012, 6:37 AM
Hi all!
The grouping column is hidden, if you refresh browser page then group rows is reset, but the grouping column will be hidden. Please, i need help.

Before refresh:

After refresh:

Example: http://www.sencha.com/examples/#grouping
You deleted row for "store.groupBy("industry");" and you will see this trouble ^
How to save last group field (GroupingView) after refresh browser page or recover the hidden column?

- GXT version: 2.2.5
- Host mode / web mode / both: All
- Browser and version: All
- Operating System: Windows 7

Vadim Kolesnikov
2 Feb 2012, 6:52 AM
I did the following:
override methods (GroupingView):

private void onGroupByClick(MenuEvent me, int colIndex) {
grid.getState().put("lastGroupField", getGroupField()); // write to grid state

protected String renderRows(int startRow, int endRow) {
String groupField = getGroupField();
boolean eg = groupField != null;
if (!showGroupedColumn) {
grid.getState().put("lastGroupField", groupField); // write to grid state
return super.renderRows(startRow, endRow);

and add to grid listener:

grid.addListener(Events.Attach, new Listener<GridEvent<Post>>() {

public void handleEvent(GridEvent<Post> be) {
Map<String, Object> state = grid.getState();
if (state.containsKey("lastGroupField")) {
store.groupBy((String) grid.getState().get("lastGroupField"));

How it is right? I don't know :)