Hi...
 I think I already posted that code snippet to the list, but here again just 
for you! ;)
The code expands all nodes in my tree, and preselects a node.
After all is done, it publishes a topic to notify a sx:div to refresh...

Possibly not the best solution, but working fine for me!
dojo.event.topic.subscribe("tree/treeCreate", function treeCreated(node) {
    var nodes = dojo.widget.getWidgetsByType("StrutsTreeNode");
    var i;
    for(i=0; i< nodes.length; i++) {
        nodes[i].expand();
    }
    var node = dojo.widget.getWidgetById("<%= 
request.getSession().getAttribute("PreselectedCategory") %>");
    node.expand();
    node.markSelected();
    document.DocumentListSelection.NodeID.value = <%= 
request.getSession().getAttribute("PreselectedCategory") %>;
    dojo.event.topic.publish('ListSelectionFilled');
});
Regards
Jan



Von: Narayana S
Gesendet: Di 07.10.2008 12:23
An: Struts Users Mailing List
Betreff: Re: Tree default expanded ??


Hello.

         Please any one tell me a solution to this problem? can we do this
in struts? if not suggest me another alternative to build tree control!! i
am kind of stuck with this tree... it is killing me...

On Tue, Oct 7, 2008 at 12:12 PM, Jukka Välimaa <[EMAIL PROTECTED]>wrote:

> I don't know. One thing to try might be to run the expansion script after
> you're sure the tree widget has been rendered.
> Jukka
>
> On Wed, Oct 1, 2008 at 9:19 AM, Narayana S <[EMAIL PROTECTED]> wrote:
>
> > Hi,
> >
> >       Thanks for your reply, i tried this code but it is returning
> > nodes.length as zero though i have a tree with 1 root and 3 child nodes
> for
> > root. this is my code snippet
> > *tree
> >
> > *<sx:tree id="tree1" rootNode="%{rootField}"
> > childCollectionProperty="children" nodeIdProperty="fieldID"
> > nodeTitleProperty="fieldName" treeSelectedTopic="treeSelected"
> > expandedNotifyTopics="treeExpanded" />
> >
> > *javascript*
> >
> > <script>
> > var nodes =
> dojo.widget.manager.getWidgetsByType('struts:StrutsTreeNode');
> >     alert("Number of nodes"+nodes.length);
> >     for( var i=0; i < nodes.length; i++){
> >        nodes[i].expand();
> >    }
> > </script>
> >
> > what is the problem? am i missing anything? please help me to solve this
> > issue.
> >
> > On Tue, Sep 30, 2008 at 7:49 PM, Jukka Välimaa <[EMAIL PROTECTED]
> > >wrote:
> >
> > > As far as I know, it is not possible to expand tree widget server-side.
> > > Client-side, javascript can be used to open the tree, like so:var nodes
> =
> > > dojo.widget.manager.getWidgetsByType('struts:StrutsTreeNode');
> > > for( var i=0; i < nodes.length; i++){
> > >     nodes[i].expand();
> > > }
> > >
> > > Jukka
> > >
> > > On Tue, Sep 30, 2008 at 4:59 PM, Narayana S <[EMAIL PROTECTED]>
> > > wrote:
> > >
> > > > any one who worked on tree control plz give some helping hand....
> > > >
> > > >
> > > >
> > > > On Fri, Sep 26, 2008 at 3:34 PM, Narayana S <[EMAIL PROTECTED]>
> > > > wrote:
> > > >
> > > > > Hi
> > > > >      Is it possible to display a tree expanded by default?
> > > > > I am using struts 2.1.2 dojo-plugin to create the tree structure.
> any
> > > one
> > > > > used tree...plz help me
> > > > >
> > > >
> > >
> >
>

Reply via email to