This is a migrated thread and some comments may be shown as answers.

[Solved] problem withh single click opening nodes

2 Answers 85 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
quentinjs
Top achievements
Rank 1
quentinjs asked on 05 Oct 2010, 05:15 PM
I have a TreeView that will:
    * if I click a node - fire a GET to the server to update the page -> this allows me to prsent data that is related to the node selected.
    * double click will expand the node

I have tried the example posted in the forums to expand a node on a single click and it works, BUT the click will only do the GET for the FIRST click.  After that all it does is expand/collapse the TreeView on a single click. 

Also the Expander() code doesn't work at all for me.  Any ideas why?   
<script type="text/javascript">
    function onSelect() { }
    function onTreeViewLoad() {
        var treeview = $('#TreeView').data('tTreeView');

        $(treeview.element)
            .delegate('div:not(.t-state-disabled) > .t-in''click', $.telerik.delegate(treeview, treeview.nodeClick))
    }
</script>

<script runat="server">
    public void Expander(TreeViewItem item)
    {
        if (item.Parent == nullreturn;
        item.Expanded = true;
        Expander(item.Parent);
    }
</script>

<% Html.Telerik().TreeView()
        .Name("TreeView")
        .ClientEvents(events => events
//                .OnSelect("onSelect")
                .OnLoad("onTreeViewLoad"))         
        .BindTo(Model.Categories, mappings => 
        {
            mappings.For<Category>(binding => binding
                    .ItemDataBound((item, category) =>
                    {
                        item.Text = category.Name;
//                        item.ControllerName = "Category";
//                        item.ActionName = "Term";
                        item.Value = category.Id.ToString();
                        item.Action<CategoryController>(xx => xx.Index(category.Id, null""false""""));
//                        if (category.Id == 8) 
//                          Expander(item);

                    })
                    .Children(category => category.Categories));
            mappings.For<Category>(binding => binding
                    .ItemDataBound((item, subcategory) =>
                    {
                        item.Text = subcategory.Name;
//                        if (item.Value == "8") 
//                            Expander(item);
                    }));
        }).Render();
  
%>

2 Answers, 1 is accepted

Sort by
0
quentinjs
Top achievements
Rank 1
answered on 07 Oct 2010, 03:12 PM
Help?
0
quentinjs
Top achievements
Rank 1
answered on 14 Oct 2010, 12:00 AM
Okay...  this is a long time to wait for a response.... 
Tags
TreeView
Asked by
quentinjs
Top achievements
Rank 1
Answers by
quentinjs
Top achievements
Rank 1
Share this question
or