Toolbar

The toolbar element having the number of tools, and each tool can be configurable.

Toolbar items

The toolbar having the list of items to perform various operations and grouped into some categorizes.

From below you can see the available toolbar items and its categorization:

  • javascript
  • // all tools grouped under the below categories
    
            tools: {
    
                    creation: ["NewFolder"],
    
                    navigation: ["Back", "Forward", "Upward"],
    
                    addressBar: ["Addressbar"],
    
                    editing: ["Refresh", "Upload", "Delete", "Rename", "Download"],
    
                    copyPaste: ["Cut", "Copy", "Paste"],
    
                    getProperties: ["Details"],
    
                    searchBar: ["Searchbar"],
    
                    layout: ["Layout"],
                    
                    sortBy: ["SortBy"]
    
            },
    
            // all tools categories are placed in the toolbar by the below order
    
            toolsList: ["layout", "creation", "navigation", "addressBar", "editing", "copyPaste", "sortBy", "getProperties", "searchBar"]

    The following table explains the functionality of each toolbar item:

    Tool name Description
    NewFolder

    It creates a new folder on the current directory.

    While click on the NewFolder item, the dialog displays to get the folder name. Based on the user input, FileExplorer creates new folder on the current directory. Also

    createFolder

    event will be triggered when new folder is created successfully in the file system.



    Back

    It navigates to the previous directory from the user history. When the backward history is not available when it is disabled state.



    Forward

    It navigates to the next directory from the user history. When the forward history is not available when it is disable state.



    Upward

    It navigates to the parent directory of the current folder.



    Address bar

    The Address bar is the textbox which displays the path of the current directory, as a series of its parent directory separated by slash (“/”).

    And the address bar is an editable area, so you can enter any directory’s path to a quick navigation.



    Refresh

    It refreshes the current directory.



    Upload

    It uploads a file or list of files into the current directory.

    And you can customize the upload configurations, for details check

    here

    .



    Delete

    It delete the current selected file or folder. The delete icon is enable state if you select any file or folder.

    If you selected the multiple files, it deletes all the selected items.



    Rename

    This is used to rename the current selected file or folder. The rename icon is enable state if you select any file or folder.

    Even if you selected multiple files, it renames the last selected file only.



    Download

    It downloads the selected files. The download icon is enable state if you select any file or folder.

    The

    beforeDownload

    event will be triggered before the files are downloaded.

    If you select multiple files, it downloads all the files in a zip format.



    Cut

    It makes the copy of the selected files or folders into the clipboard. When the user paste the files in any location, the files are removed from the source location. The

    cut

    event will be triggered when files or folders are removed from the source.



    Copy

    It makes the copy of the selected files or folders into the clipboard. When the user paste the files, the copy of the files are pasted in the target location. The

    copy

    event will be triggered when file or folder is copied.



    Paste

    It pastes the files from the clipboard into the currently selected folder.

    Note: Only when the files are copied into the clipboard it is enabled. The

    paste

    event will be triggered when file or folder is pasted.



    Details

    It displays the details of the current selected file or folder.



    Search bar

    The Search bar is the textbox which is used to search the files from the current directory. It list the files based on the user search.

    The search behavior of the Search bar can be customize, for details check

    here

    .



    Sort By

    It's used to sorting the files and folders from the current directory.The sorting can be done based on the columns available from grid,in both ascending and descending order.

    Toolbar Visibility

    The visibility of the toolbar can be customized through the showToolbar property. By disabling this property you can remove the toolbar from FileExplorer. Also you can remove the particular toolbar item by using removeToolbarItem method.

  • javascript
  • /// <reference path="tsfiles/jquery.d.ts" />
    /// <reference path="tsfiles/ej.web.all.d.ts" />
    
    module ExplorerComponent {
        $(function () {
    
                var fileSystemPath = "http://js.syncfusion.com/demos/ejServices/Content/FileBrowser/";
    
                var ajaxActionHandler = "http://js.syncfusion.com/demos/ejServices/api/FileExplorer/FileOperations";
    
                    var file = new ej.FileExplorer($("#fileExplorer"), {
    
                    path: fileSystemPath,
    
                    ajaxAction: ajaxActionHandler,
    
                    // hides the toolbar
    
                    showToolbar: false
    
                });
    
            });
      }

    Toolbar Configuration

    As you can see the available toolbar items from here. From the list of available items, you can configure and group your required toolbar items only through the tools property. And also you can arrange the toolbar items by the toolsList property.

  • javascript
  • /// <reference path="tsfiles/jquery.d.ts" />
    /// <reference path="tsfiles/ej.web.all.d.ts" />
    
    module ExplorerComponent {
        $(function () {
    
                var fileSystemPath = "http://js.syncfusion.com/demos/ejServices/Content/FileBrowser/";
    
                var ajaxActionHandler = "http://js.syncfusion.com/demos/ejServices/api/FileExplorer/FileOperations";
    
                var file = new ej.FileExplorer($("#fileExplorer"), {
    
                    path: fileSystemPath,
    
                    ajaxAction: ajaxActionHandler,
    
                    // denotes the order of the tools categories
    
                    toolsList: ["creation", "navigation", "addressBar", "copyPaste", "searchBar"],
    
    
    
                    // mentions the required tool items under each category 
    
                    tools: {
    
                        creation: ["NewFolder"],
    
                        navigation: ["Back", "Forward", "Upward"],
    
                        addressBar: ["Addressbar"],
    
                        copyPaste: ["Cut", "Copy", "Paste"],
    
                        searchBar: ["Searchbar"]
    
                    }
    
                });
    
            });
     }

    The Search bar can be customize through the filterSettings property. By default the search doesn’t consider the case sensitivity, and the search works based on filter type.

    The FileExplorer allows the following filter types in the search functionality.

    • Starts with
    • Contains
    • Ends with
  • javascript
  • ej.FileExplorer.filterType = {
    
                /**  Supports to search text with startswith  */
    
                StartsWith: "startswith",
    
                /**  Supports to search text with contains */
    
                Contains: "contains",
    
                /**  Supports to search text with endswith */
    
                EndsWith: "endswith",
    
            };

    So you can configure the filter type with case sensitivity like below:

  • javascript
  • /// <reference path="tsfiles/jquery.d.ts" />
    /// <reference path="tsfiles/ej.web.all.d.ts" />
    
    module ExplorerComponent {
    
        $(function () {
    
                var fileSystemPath = "http://js.syncfusion.com/demos/ejServices/Content/FileBrowser/";
    
                var ajaxActionHandler = "http://js.syncfusion.com/demos/ejServices/api/FileExplorer/FileOperations";
    
                $("#fileExplorer").ejFileExplorer({
    
                    path: fileSystemPath,
    
                    ajaxAction: ajaxActionHandler,
    
                    filterSettings: {
    
                        // it enables the case sensitive search
    
                        caseSensitiveSearch: true,
    
                        // it changes the search filter type as “startswith”
    
                        filterType: ej.FileExplorer.filterType.StartsWith
    
                    }
    
                });
    
            });
       }

    Custom Tool in Toolbar

    From the toolbar items you can see the list of built-in tools to perform the operations. Along with this built-in tools, you can add your custom tool with the custom functionality.

    You can find an online demo sample of FileExplorer with custom tool from here.

  • javascript
  • /// <reference path="tsfiles/jquery.d.ts" />
    /// <reference path="tsfiles/ej.web.all.d.ts" />
    
    module ExplorerComponent {
    
        $(function () {
    
                var fileSystemPath = "http://js.syncfusion.com/demos/ejServices/Content/FileBrowser/";
    
                var ajaxActionHandler = "http://js.syncfusion.com/demos/ejServices/api/FileExplorer/FileOperations";
    
                var file = new ej.FileExplorer($("#fileExplorer"), {
    
                    path: fileSystemPath,
    
                    ajaxAction: ajaxActionHandler,
    
                    // denotes the order of the tools categories
    
                    toolsList: ["creation", "navigation", "addressBar", "copyPaste", "searchBar", "customTool"],
    
    
    
                    // defines the tool items for customTool category 
    
                    tools: {
    
                        customTool: [{
    
                            name: "Help",
    
                            tooltip: "Help ",
    
                            css: "e-fileExplorer-toolbar-icon Help",
    
                            action: function () {
    
                                // handle the click handler of custom tool 
    
                                alert("custom tool item clicked");
    
                            }
    
                        }]
    
                    }
    
                });
    
            });
        }

    Define the CSS that needs to apply for the custom tool.

  • css
  • .e-fileExplorer-toolbar-icon {
                height: 22px;
                width: 22px;
                font-family: 'ej-webfont';
                font-size: 18px;
                margin-top: 2px;
                text-align: center;
            }
    
            .e-fileExplorer-toolbar-icon.Help:before {
                content: "\e72b";
            }

    Enable / Disable the Toolbar Item

    Each toolbar item can be enabled or disabled through the below client-side public methods.

    These methods accepts the tool name as the parameter. It also allows the parameter as tool item index or the jQuery object of the tool item.

  • javascript
  • /// <reference path="tsfiles/jquery.d.ts" />
    /// <reference path="tsfiles/ej.web.all.d.ts" />
    
    module ExplorerComponent {
    
        $(function () {
    
            var fileExpObj = new ej.FileExplorer($("#fileExplorer"), { 
    
            });
    
                // this disables the NewFolder item
    
                fileExpObj.disableToolbarItem("NewFolder");
    
                // this also disables the NewFolder item (since index of NewFolder is 0)
    
                fileExpObj.disableToolbarItem(0);
    
    
    
                // this enables the NewFolder item
    
                fileExpObj.enableToolbarItem("NewFolder");
    
            });
       }

    Enable / Disable the custom added tool in Toolbar Item

    If you want to enable / disable the custom added tool in toolbar, you need to pass the corresponding li elements of custom added tool in enableToolbarItem / disableToolbarItem method of FileExplorer. Since we have consider this custom tool as a object type.

  • javascript
  • var fileExpObj = $("#fileExplorer").data("ejFileExplorer");
            
            //tool is a cssClass of FileExplorer 
            // this disables the custom tool item 
            
            var li = $(".tool").find(".Help").closest('li'); 
            fileExpObj.disableToolbarItem(li); 
            
            // this enables the custom tool item 
            fileExpObj.enableToolbarItem(li);

    Customizing the Upload Functionality

    FileExplorer helps you to upload the file using Upload component. File upload can be done through the toolbar item or context menu item. The uploadSettings property is used to configure the upload functionalities.

    This property has the below sub properties with the default values:

  • javascript
  • uploadSettings: {
    
                    allowMultipleFile: true,
    
                    maxFileSize: 31457280,
    
                    autoUpload: false
    
            }

    allowMultipleFile: This property used to control the behavior of multiple files upload and this was enabled by default so you can upload multiple files at a time. If you disable this allowMultipleFile property then you can upload only one file at a time.

    maxFileSize: The property limits the maximum file size to upload. It accepts the value in bytes.

    autoUpload: when you enable this property, the upload action performed automatically after select the files. When you disable this property, it shows a confirmation dialog with the selected file details and perform the upload action on press the “upload” button.

    During upload process following events will be triggered, <p>beforeUploadSend</p>
    , <p>beforeUploadDialogOpen</p>
    , <p>beforeUpload</p>
    , <p>uploadError</p>
    , <p>uploadSuccess</p>
    and <p>uploadComplete</p>
    . You can customize the upload settings with these events

  • javascript
  • /// <reference path="tsfiles/jquery.d.ts" />
    /// <reference path="tsfiles/ej.web.all.d.ts" />
    
    module ExplorerComponent {
    
        $(function () {
    
                var fileSystemPath = "http://js.syncfusion.com/demos/ejServices/Content/FileBrowser/";
    
                var ajaxActionHandler = "http://js.syncfusion.com/demos/ejServices/api/FileExplorer/FileOperations";
    
                var file = new ej.FileExplorer($("#fileExplorer"), {
    
                    path: fileSystemPath,
    
                    ajaxAction: ajaxActionHandler,
    
                    uploadSettings: {
    
                        // it disables the multi file upload functionality
    
                        allowMultipleFile: false,
    
                        // it enables the auto upload functionality
    
                        autoUpload: true
    
                    }
    
                });
    
            });
      }