PDA

View Full Version : Focus Tree Row



micgala
22 Apr 2011, 2:21 AM
Hi.

Imagine I have just added a new node to a certain parent in my tree.
No imagine I want the viewer to focus on the row where the new node was added.

Right now, I'm doing it like this:


treeGrid.getView().focusRow(treeGrid.getView().findRowIndex(treeGrid.getView().getRow(model)));


Is there an easier way of accomplish this?

Thanks,
Michel.

sven
22 Apr 2011, 3:07 AM
treeGrid.getView().focusRow(treeGrid.getStore().indexOf(model)));

micgala
22 Apr 2011, 3:42 AM
Tks Sven.

I was trying that with the wrong store... indexOf of the TreeListStore was returning the index inside the parent only...
but getStore() returns the listStore... which is the right one to use for this.

Regards,
Michel.

Ekambos
22 Apr 2011, 11:38 AM
You guys realize that such a call :


treeGrid.getView().focusRow(treeGrid.getView().findRowIndex(treeGrid.getView().getRow(model)));


is really bad from the OO Design standpoint

if the grid is supposed the setfocus on a row

why not add a method like


treeGrid.focusRow(rowIndex);


and let the grid handle all that stuff ?

with the actual implementation the caller needs to know too much stuff about the grid.

cheers

Alain