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

Multiple databound

3 Answers 138 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Philippe
Top achievements
Rank 1
Philippe asked on 01 Apr 2015, 08:38 AM
Hello,

Here is the situation. I have a treeview that basically represents directory, sub-directory and files. For some reasons, I can't use the LoadOnDemand option. So I load all the tree in my controller.
Everything works fine except that it seems the Databound event is triggered for each directory and subdirectory. I was expecting the event to be triggered only once when all data are "loaded" from the datasource.
At the end, I need to expand some nodes everytime the datasource is refreshed

This is my treeview

    @(Html.Kendo().TreeView()
        .Name("treeview")
        .DataTextField("name")
        .LoadOnDemand(false)
        .DataSource(datasource => datasource.Read(read => read.Action("Tree_Read_All", "MyController"))
        .Model(model => model.Children("childrens")))
        .DragAndDrop(true)
        .Events(events => events
            .Select("treeViewOnSelect")
            .Drop("treeViewOnDrop")
            .DataBound("treeViewDataBound")
        )
    )

Thanks in advance

3 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 03 Apr 2015, 06:50 AM

Hello Philippe,

This behavior is expected, the dataBound event is fired for every level that is loaded in the TreeView, and there is no workaround for this at the moment. You can submit this as a feature request on UserVoice, so that it is considered for implementation in a future release.

Regards,
Kiril Nikolov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Philippe
Top achievements
Rank 1
answered on 03 Apr 2015, 09:42 AM
Hello Kiril,

Thank you for your reply.

Basically, I juste want to expand the nodes that were expanded before the refresh. So I currently store all the expanded node Id before the refresh. When the operation is complete, I want to parse my tree and re-expand the nodes.

So is there a way to know when the refresh operation is complete (all the nodes are loaded).
Or maybe there is an easier way to achieve what I want to do ?

0
Kiril Nikolov
Telerik team
answered on 07 Apr 2015, 06:49 AM

Hello Philippe,

 

I am afraid that with the currently available methods and events, there is no way to know when the last item is loaded, you can see how many first level childs do you have so they will be loaded with the corresponding dataBound's and after the last one is loaded you can start the expanding from the saved selection.

 

Regards,
Kiril Nikolov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
TreeView
Asked by
Philippe
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Philippe
Top achievements
Rank 1
Share this question
or