possible to change toolbar item visibility from server side?

2 posts, 0 answers
  1. sf
    sf avatar
    103 posts
    Member since:
    Apr 2009

    Posted 21 Jul 2010 Link to this post

    Is it possible to hide/show item(s) on toolbar based on the content user selected?
    e.g. only 1 level of subfolder can be created, if user click on any level1 subfolder the Add Folder button will be hidden, if user click on a file in the root folder the delete button will be hidden

    thanks in advance

  2. Petio Petkov
    Petio Petkov avatar
    825 posts

    Posted 22 Jul 2010 Link to this post


    You can control the toolbar visibility from client-side code. The code below illustrates how to achieve it.
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <head id="Head1" runat="server"
        <form id="form1" runat="server"
        <asp:ScriptManager ID="ScriptManager1" runat="server"
        <script type="text/javascript">
            function configureToolbarItems(fileExplorer)
                //Get a reference to the RadFileExplorer's toolbar
                var toolbar = fileExplorer.get_toolbar();
                //Get commands client-side objects
                var delCommand = toolbar.findItemByValue("Delete");
                var newFolderCommand = toolbar.findItemByValue("NewFolder");
                var treeView = fileExplorer.get_tree();
                var currentlySelectedNode = treeView.get_selectedNode();
                if(currentlySelectedNode.get_parent() == treeView)
                    //Disable Delete and Enable NewFolder
                    //Enable Delete and Disble NewFolder
            function ItemSelected(fileExplorer, args)
            function OnClientFolderChange(fileExplorer, args)
            <telerik:RadFileExplorer ID="RadFileExplorer1" runat="server"
            OnClientFolderChange = "OnClientFolderChange"
                <Configuration ViewPaths="~/Files" DeletePaths="~/Files" UploadPaths="~/Files"/> 
    Also you can handle RadFileExplorer's OnItemCommand server-side event and make additional checks,e.g. 
    protected void fileExplorer_ItemCommand(object sender, RadFileExplorerEventArgs e)
            switch (e.Command)
                case "UploadFile":
                    //DO SOMETHING
                case "CreateDirectory":
                    //DO SOMETHING
                case "DeleteFile":
                    //DO SOMETHING
    Hope this helps.

    Sincerely yours,
    Petio Petkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top