How to get name or path items with custom button in Kendo FileManager

1 Answer 23 Views
FileManager
Stark
Top achievements
Rank 1
Iron
Iron
Stark asked on 12 May 2021, 07:59 AM | edited on 12 May 2021, 08:51 AM

Hi admin and everybody,

Image show result I need

I want get name or path of items inside folder. You can follow code:


<div id="fileManager"></div>
<script>
    var baseUrl = "https://demos.telerik.com/kendo-ui/service/filemanager/";

    $("#fileManager").kendoFileManager({
        dataSource: {
            transport: {
                read: function(options) {
                    var that = this;

                    $.ajax({
                        url: baseUrl + "Read",
                        dataType: "json", 
                        method: "POST",
                        data: that.parameterMap ? that.parameterMap(options.data, "read") : options.data,
                        success: function(result) {
                            options.success(result);
                        }
                    });
                },
                update: function(options) {
                    var that = this;

                    $.ajax({
                        url: baseUrl + "Update",
                        dataType: "json", 
                        method: "POST",
                        data: that.parameterMap ? that.parameterMap(options.data, "read") : options.data,
                        success: function(result) {
                            options.success(result);
                        }
                    });
                },
                create: function(options) {
                    var that = this;

                    $.ajax({
                        url: baseUrl + "Update",
                        dataType: "json", 
                        method: "POST",
                        data: that.parameterMap ? that.parameterMap(options.data, "read") : options.data,
                        success: function(result) {
                            options.success(result);
                        }
                    });
                },
                destroy: function(options) {
                    console.log(options.data.name); // can get name items
                }
            }
        },
      uploadUrl: "/kendo-ui/service/FileManager/Upload",
        toolbar: {
          items: [
            { name: "createFolder" },
            { name: "upload" },
            
            { name: "sortDirection" },
            { name: "sortField" },
            { name: "changeView" },
            { name: "spacer" },
            { name: "details" },
            { name: "search" }
          ]
        },
        contextMenu: {
          items: [
            { name: "rename" },
            { name: "delete" },
            { name: "custom", text: "Get Info", command: "MyCustomCommand", spriteCssClass:"k-icon k-i-info" }
          ]
        },
        draggable: true,
        resizable: true
    });
  
  var filemanagerNS = kendo.ui.filemanager;

        filemanagerNS.commands.MyCustomCommand = filemanagerNS.FileManagerCommand.extend({
          exec: function(options){
            var data = $("#fileManager").data("kendoFileManager").dataSource.data();
            
            console.log(options.data.name); // What I need to do here to get name with button custom?
          }
        });
</script>

1 Answer, 1 is accepted

Sort by
0
Stark
Top achievements
Rank 1
Iron
Iron
answered on 12 May 2021, 10:10 AM
I have solved my problem
Tags
FileManager
Asked by
Stark
Top achievements
Rank 1
Iron
Iron
Answers by
Stark
Top achievements
Rank 1
Iron
Iron
Share this question
or