The navigate method lets us select a folder by name. Is there a way to always select the first folder listed; by some sort of index maybe?
2 Answers, 1 is accepted
0
Aleksandar
Telerik team
answered on 31 Dec 2020, 10:35 AM
Hi Alan,
If my understanding is correct, once the FileManager loads, you would like to have the first folder selected and it's contents displayed, is that the case?
To achieve the above you can attach a handler to the dataBound event, so the handler is executed only once, using the one() method. Within this handler get a reference to the FileManager's TreeView used for navigation, find the first node, and pass its path to the FileManaget's navigate method:
$(document).ready(function () {
var filemanager = $("#filemanager").getKendoFileManager();
filemanager.one("dataBound", function(e){
var treeview = $(e.sender.navigation.find("[data-role='treeview']")).getKendoTreeView();
var firstNode = treeview.findByUid($(treeview.items()[0]).parent().attr('data-uid'));
var dataItem = treeview.dataItem(firstNode);
e.sender.navigate(dataItem.path)
});
});
Here is a runnable example that demonstrates the above-suggested approach.
I hope this helps.
Regards,
Aleksandar
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.