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

TreeView node select on RequestEnd event

1 Answer 314 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ross
Top achievements
Rank 1
Ross asked on 31 Dec 2012, 12:16 AM
After reading other various forum articles and documentation it looks like selecting the parent node (or any other node) is possible when the tree is initialised.  However, with the following code the first node is not selected.  It's a pretty simple bit of code, so would appreciate any help.

Thanks,
Ross
@(Html.Kendo().TreeView().Name("treeview")
                        .AutoBind(true)
                        .LoadOnDemand(true)
                        .DataTextField("Name")
                        .DataSource(dataSource => dataSource
                                    .Read(read => read
                                          .Action("GetNameList", "Home"))
                                          .Events(e => e.RequestEnd("onRequestEnd"))
                                          )
)
 
<script>
    var treeview;
     
    $(document).ready(function () {
        treeview = $("#treeview").data("kendoTreeView");
    });
 
    function onRequestEnd() {
        treeview.select(".k-first");
    }
</script>

1 Answer, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 31 Dec 2012, 02:40 PM
Hello Ross,

Use the dataBound event of the TreeView - because the requestEnd event of the dataSource is triggered before the TreeView is actually reconstructed and thus the selection of a node at this time will be obliterated.

Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
TreeView
Asked by
Ross
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or