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

Select First folder

2 Answers 380 Views
FileManager
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Veteran
Alan asked on 29 Dec 2020, 07:26 PM

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

Sort by
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/.

0
Alan
Top achievements
Rank 1
Veteran
answered on 04 Jan 2021, 01:22 PM
Great! Thank you, exactly what I was looking for.
Tags
FileManager
Asked by
Alan
Top achievements
Rank 1
Veteran
Answers by
Aleksandar
Telerik team
Alan
Top achievements
Rank 1
Veteran
Share this question
or