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

Use the built-in newFolder dialog with a custom button

3 Answers 30 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Wael
Top achievements
Rank 1
Wael asked on 24 Oct 2019, 09:27 PM

I have created a custom button to set/change a file tags (this would be a DB column I will handle). I am trying to call/open the new folder dialog and use it's textbox to set or modify a file tags, my code is:

 

<telerik:RadFileExplorer runat="server" ID="telerikFileExplorer" RenderMode="Lightweight" Width="650px" Height="480px"
    OnExplorerPopulated="telerikFileExplorer_ExplorerPopulated" OnClientLoad="fileExplorerInit" OnClientItemSelected="fileExplorerItemSelected" OnClientFolderChange="fileExplorerFolderChanged">
    <Configuration AllowFileExtensionRename="false" AllowMultipleSelection="true" />
</telerik:RadFileExplorer>

<script type="text/javascript">
    function fileExplorerInit(fileExplorer, args) {
        var toolbar = fileExplorer.get_toolbar();
        toolbar.add_buttonClicked(toolbarClicked);
        setButtonEnableState(fileExplorer, '', 'ChangeTags');
    }
    function toolbarClicked(toolbar, args) {
        var buttonValue = args.get_item().get_value();
        if (buttonValue == 'ChangeTags') {
            //Call open NewFolder dialog and post to update new value;
        }
    }
    function fileExplorerItemSelected(fileExplorer, args) {
        setButtonEnableState(fileExplorer, args.get_item().get_extension(), 'ChangeTags');
    }
    function fileExplorerFolderChanged(fileExplorer, args) {
        setButtonEnableState(fileExplorer, args.get_item().get_extension(), 'ChangeTags');
    }
    function setButtonEnableState(fileExplorer, extension, command) {
        var button = fileExplorer.get_toolbar().findItemByValue(command);
        button.set_enabled(!(typeof (extension) == 'undefined' || extension == null || extension == ''));
    }
</script>

3 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 29 Oct 2019, 12:07 PM

Hi Wael,

RadFileExplorer does not expose a public method for showing the Rename dialog on demand (you can call the rename() for an item, but it will not pop a dialog), but you can show with in a similar way:

            function toolbarClicked(toolbar, args) {
                var buttonValue = args.get_item().get_value();

                if (buttonValue == 'ChangeTags') {
                    //Call open NewFolder dialog and post to update new value;
                    var fileItem = $find("telerikFileExplorer").get_selectedItem();
                    var fileName = fileItem.get_name();
                    fileName = fileName.substring(0, fileName.lastIndexOf("."));
                    var fileRenameCallback = Function.createCallback(fileExplorer._onFileRenameDelegate, fileItem);

                    fileExplorer._showPromptDialog(fileRenameCallback, {
                        title: "Rename",
                        value: fileName,
                        inputValidator: fileExplorer._validateFileNameInputDelegate,
                        timeout: 10
                    });

                }
            }

 

Regards,
Vessy
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Wael
Top achievements
Rank 1
answered on 07 Nov 2019, 12:43 AM

Thank you so much Vessy 😊

 

0
Vessy
Telerik team
answered on 07 Nov 2019, 07:47 AM

Hi,

You are absolutely welcome, Wael :)

Regards,
Vessy
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
FileExplorer
Asked by
Wael
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Wael
Top achievements
Rank 1
Share this question
or