PDA

View Full Version : Store the GXT Grid state for the user in the cookie



navi75
2 Aug 2010, 6:43 PM
I would like to persist the Grid configuration state information per user in a cookie.

For example if the user selects one of the Grid Column to be ascending or hide one of the columns from the Grid in a cookie so that next time when the Grid is displayed for the same user it should display the Grid configuration state infromation from the cookie.

Any help would be appreciated. If someone has a sample code as How i can use the GXT CookieProvider to store the Grid state information per user.

Thanks.

sven
3 Aug 2010, 2:23 AM
State management is already build into many components, so also into grids.

Simple make the grid statefull and give it a unique stateId:


grid.setStateful(true);
grid.setStateId("mygridsuniqeueid");

navi75
3 Aug 2010, 8:08 AM
Hi Sven,

For each user i should create a uniqueId of the grid state and then store the uniqueId in the cookie.

ForExample HashMap obj = new HashMap();
obj.put("user1","uniqueId");

with GXT CookieProvider.set(obj)

Thanks.

sven
3 Aug 2010, 8:39 AM
Can you please explain the logic behind the code you just posted? I dont understand it. Have you tried the code i gave you?

navi75
3 Aug 2010, 9:58 AM
Sven,

My apologies for the confusion with cookie logic.

I got your logic that we can use the grid stateful feature and in that case we do not need to store the user specific grid state information in the cookie.

I will try the logic which you have given.

Thanks.