TreeGrid with checkbox appearance

Hello, i’m using smartGwt 2.4 and i’m making a TreeGrid with option setSelectionAppearance(SelectionAppearance.CHECKBOX);

He is on a Window and when i check i save and i store data somewhere. But when i reopen my Window i need to check back nodes who matches datas.

This is ok i can select back all of them by retrieving nodes matching datas and set isSelected to true but my problem is that i want the parents be checked too with partial selection or full selection.

How can i make that ? is there anyway to make that automaticly or should i get parent and select it and its parent, … ?

And after i’d like to open all nodes that are selected, how can i make that ?

Thanks for your answers

up please, i didn’t find

Thanks

Try something along those lines:

treeGrid.addDataArrivedHandler(new DataArrivedHandler() {
                        @Override
                        public void onDataArrived(DataArrivedEvent event) {
                            treeGrid.selectRecords(yourSelectedRecordArray);
                            treeGrid.getTree().openFolders((TreeNode[]) treeGrid.getSelection());
                            });
                        }
                    });

ps. actually, you might have to change those two lines to open the selected nodes first, and select them afterwards, I remember having some issues with selecting invisible nodes.

hope this helps,
Andrius J.

Thanks for your answer.

In fact i used the property isSelected to true to all my previously selected values.

and (TreeNode) treeGrid.getSelection() throw a castClassException so i made a TreeNode with retrieving parent to the root of my tree and.

So this is ok now.

Just one last thing is that i check all the parent of my selected value but when the parent has one or more unselected values it appears like full check althoug i set property setShowPartialSelection to true.

Any idea to make that ?

Thanks