On 9/27/07, dperez <[EMAIL PROTECTED]> wrote:
>
>
> Thanks Derrell for your quick answer.
> What I'm trying to do is on load to select initially an item.
> This is the code:
>
>                         var mod = tree.getDataModel(), dat = mod.getData
> ();
>                         for (var i = 0; i < dat.length; i++) {
>                                 var d = dat[i];
>                                 if (d && d.columnData && d.columnData[1]
> == goToItem) {
>                                         while (1) {
>                                                 var parent =
> d.parentNodeId;
>                                                 if (!parent) {
>                                                         break;
>                                                 }
>                                                 d = dat[parent];
>                                                 if (!d.bOpened) {  // HERE
> IS WHERE I'M FINDING d.nodeId==null
>
> tree.nodeToggleOpened(d);
>                                                 }
>                                         }
>                                         var row = mod.getNodeRowMap()[i];
>                                         if (row != null) {
>                                                 
> tree.getSelectionModel().setSelectionInterval(row,
> row);
>                                                 //tree.scrollCellVisible(0,
> row);
>                                         }
>                                         break;
>                                 }
>
> Probably I will have to open first the ancestors that are less nested.
>

All right.  Yes, you need to open ancestors.  You can recursively follow
d.parentNodeId to do so.  When you call tree.nodeToggleOpened(d), it will
have no immediate effect if ancestors aren't already opened, so you'll want
to open them first.  You may want to manually manipulate the ancestors'
bOpened flag rather than calling nodeToggleOpened() on each one because the
latter recalculates the rendered row array on each call, and you need that
only once when you're all done with the recursive calls.  At the end of your
recursive calls, you can then issue a single mod.setData() call to rerender
everything.

Secondly, you can take advantage of a currently undocumented (but should be
documented) feature: the index of the node in the data model is its nodeId!
This means that your loop variable i is actually nodeId.  That's probably
the key piece of information that you required.  The reason that nodeId is
added when the row is rendered is that the index in the rowArr has no
relation to the node id, so the nodeId field is needed if one wants to be
able to find the node id given a row (e.g. via a click).

Cheers,

Derrell
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to