Template Manager Upload and New Folder

4 posts, 1 answers
  1. Jack
    Jack avatar
    128 posts
    Member since:
    May 2003

    Posted 22 Feb 2014 Link to this post

    Hi,

    It appears that we cannot create new folders without allowing uploads in the template manager.
    I need to create new folders but not allow uploads - is this possible please? ..or have I missed something?

    Cheers,

    Jack
  2. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 26 Feb 2014 Link to this post

    Hello Jack,

    You are correct, folders can be created only if the UploadPaths property is correctly set. The logic for file uploading and folder creation needs the same configuration and currently I cannot suggest a proper approach to allow only the folder creation.

    Nevertheless, I believe that removing the HTML button should fit your expectation, this can be done with a simple custom implementation that gets the element and removes it from the DOM:
    <telerik:RadEditor runat="server" ID="RadEditor1" OnClientCommandExecuted="OnClientCommandExecuted">
        <TemplateManager ViewPaths="~/Folder" UploadPaths="~/Folder" />
    </telerik:RadEditor>
     
    <script type="text/javascript">
        function OnClientCommandExecuted(editor, args) {
            var command = args.get_commandName();
            if (command === "TemplateManager") { // You should check for all desired file browser dialogs
                var dialog = editor.get_dialogOpener()._dialogContainers[command];
     
                dialog.add_pageLoad(function () {
                    var oDoc = dialog.get_contentFrame().contentDocument;
                    $telerik.$(oDoc).find(".icnUpload").remove();
                })
            }
        }
    </script>


    Regards,
    Ianko
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jack
    Jack avatar
    128 posts
    Member since:
    May 2003

    Posted 26 Feb 2014 in reply to Ianko Link to this post

    Hi Ianko,

    Yes that works great - Thank you!

    Jack
  5. Answer
    Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 26 Feb 2014 Link to this post

    Hi Jon,

    After some further investigation I found that the users will be able to upload files through the context menus.

    You can refer to this updated example:
    <telerik:RadEditor runat="server" ID="RadEditor1" OnClientCommandExecuted="OnClientCommandExecuted">
        <TemplateManager ViewPaths="~/Paths" UploadPaths="~/Paths"/>
    </telerik:RadEditor>
     
    <script type="text/javascript">
        function OnClientCommandExecuted(editor, args) {
            var command = args.get_commandName();
            if (command === "TemplateManager") { // You should check for all desired file browser dialogs
                var dialog = editor.get_dialogOpener()._dialogContainers[command];
                 
                dialog.add_pageLoad(function () {
                    var oDoc = dialog.get_contentFrame().contentDocument;
                    var oWin = dialog.get_contentFrame().contentWindow;
                    var fileExplorerID = oDoc.getElementsByClassName("RadFileExplorer")[0].id;
                    var feControl = oWin.$find(fileExplorerID);
                    // Get context upload button
                    var gridContextUpload = feControl.get_gridContextMenu().findItemByText("Upload");
                    var gridContextItems = feControl.get_gridContextMenu().get_items();
                    // Get tree upload button
                    var treeContextUpload = feControl.get_tree().get_contextMenus()[0].findItemByText("Upload");
                    var treeContextItems = feControl.get_tree().get_contextMenus()[0].get_items();
     
                    gridContextItems.remove(gridContextUpload);
                    treeContextItems.remove(treeContextUpload);
                    $telerik.$(oDoc).find(".icnUpload").remove();
                })
            }
        }
    </script>


    Regards,
    Ianko
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top