SmartGWT TreeGrid Selection
Posted
by wonderbread988
on Stack Overflow
See other posts from Stack Overflow
or by wonderbread988
Published on 2009-07-23T20:47:11Z
Indexed on
2010/04/08
4:03 UTC
Read the original article
Hit count: 810
smartgwt
|web-applications
I have a SmartGWT webapp that uses a TreeGrid with a dataSource. I would like this treeGrid to preselect values saved in a cookie. I have gotten the value to be saved in the cookie correctly, however I have tried several different methods of getting the treeGrid to select these values and I can not get it to work. I am attempting to do this in the onmoduleLoad method in my entry point.
I have tried:
Cookies.setCookie( "selectedUnit", TreeGrid.getSelectedPaths() )
to set the cookie and then when the page is reloaded:
TreeGrid.setSelectedPaths( Cookies.getCookie("selectedUnit" )
When I could not get that to work, I tried storing just the id of the item selected:
Cookies.setCookies( "selectedUnit", TreeGrid.getSelected().getAttribute("id") )
and then onLoad attempting to find that record and select it:
TreeGrid.selectRecord( TreeGrid.getTree().find("id", Cookies.getCookie("selectedUnit") ) )
This did not work either, so finally I tried storing TreeGrid.getSelectedState() and upon retrieving that value form the cookie onLoad, passing it to TreeGrid.setSelectedState() similar to my first attempt, but passing state instead of path.
I could not get any of these things to work. Can I not tell the TreeGrid to select an item in the 'OnmoduleLoad' method? Is this action only valid after the TreeGrid has been drawn? If that is the case where and how can I do this?
Thank you in advance for any help you can give.
© Stack Overflow or respective owner