+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / File Manager - Hide Folders

File Manager - Hide Folders

27 posts, 0 answered
  1. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    19 Aug 2009
    Link to this post
    Hi there,

    When I deploy my site and hand over admin to the client they'll be doing all admin work/content managment etc. This will most likely include uploading files using the file manager. They need (or have requested) full admin access so they are in the default administrator role which has access to the file manager. However, since they are far from being technical or developer types I am concerned that they may "explore" and possibly edit/upload/delete things in the Sitefinity folder for example. Is there an easy way to have this folder "filtered" or "hidden" from the tree view so that the file manager can't access it? In the case that something needs to be uploaded there it will most likely be done by me and using ftp so it's ok if this is a hard coded fix and not something based on roles (although that would be nice).

    Thanks in advance,
    Phill
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    19 Aug 2009
    Link to this post
    Hi Phill Hodgkinson,

    Below is a sample code that illustrates how to hide "Sitefinity" folder from the RadTreeView in Files section of Sitefinity's backend. The following logic is used for RadGrid control.

    protected override void OnPreRender(EventArgs e) 
        { 
            base.OnPreRender(e); 
            if (fileManager.Mode == FileManagerMode.Upload) 
                mainPanel.Attributes.Add("class""wrapperUpload"); 
            else 
                mainPanel.Attributes.Add("class""wrapperBrowser"); 
                var treeView = FindControlRecursive(foldersNavigation, "foldersTree"as RadTreeView; 
                var radGrid = FindControlRecursive(fileManager, "fileGrid"as RadGrid; 
            if (UserManager.IsCurrentUserInRole("test")) 
            { 
                RadTreeNode node = null
                foreach (var tnode in treeView.GetAllNodes()) 
                { 
                    if (tnode.Text == "Sitefinity"
                    { 
                        node = tnode; 
                        tnode.Visible = false
                        radGrid.ItemDataBound += new GridItemEventHandler(radGrid_ItemDataBound); 
                    } 
                    else 
                    { 
                        tnode.Visible = true
                    } 
                } 
                while (node.ParentNode != null
                { 
                    node.ParentNode.NavigateUrl = "#"
                    node = node.ParentNode; 
                    node.Visible = true
                } 
            } 
     
     
        } 
        void radGrid_ItemDataBound(object sender, GridItemEventArgs e) 
        { 
            if ((e.Item.ItemType == GridItemType.Item) || (e.Item.ItemType == GridItemType.AlternatingItem) || (e.Item.ItemType == GridItemType.EditItem)) 
            { 
                if (e.Item is GridDataItem) 
                { 
                    GridDataItem dataItem = e.Item as GridDataItem; 
                    if (dataItem["Name"].Text.Equals("Sitefinity") && UserManager.IscurrentUserInRole("test")) 
                    { 
                        dataItem.Display = false
                    } 
                } 
            } 
        } 
     
        private Control FindControlRecursive(Control root, string id) 
        { 
            if (root.ID == id) 
            { 
                return root; 
            } 
     
            foreach (Control c in root.Controls) 
            { 
                Control t = FindControlRecursive(c, id); 
                if (t != null
                { 
                    return t; 
                } 
            } 
     
            return null
        }  


    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    19 Aug 2009
    Link to this post
    Thanks Ivan,

    This is just what I was looking for. As soon as the bug with renaming files is fixed I'll be able to use it ;) For now I've gone with a hack of hiding the tree and filemanager and used the Telerik FileExplorer control instead. 

    Thanks again!
    Phill
  4. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    06 Jan 2010
    Link to this post
    Does the sample code that Ivan posted work? Or is there still a bug and should go with the way Phill did it?  And is there any information on that way?

    I have a client that will need to upload hundres'd of PDF's and it would be easiest for them to use the File Manager under the Files tab but of course don't want them accessing/seeing the other files/folders.

    Thank you.
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    06 Jan 2010
    Link to this post
    Hello Laura,

    The sample code posted by me works without problems.The problem that Phill is talking about is a completely different thing  and it is related to the file/folders renaming. So the short answer:

    -Implementing some restrictions to the RadGrid and TreeView will work without problems.
    - The bug related to the renaming of file/folders persist and it will not be sorted for the 3.x versions before we relates Sitefinity 4.0.


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    06 Jan 2010
    Link to this post
    Ivan - Thank you as always for your quick reply!
  7. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    06 Jan 2010
    Link to this post
    It would be nice though if we could diplay folders based on roles.  Admin seeing all of course.
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    06 Jan 2010
    Link to this post
    Hello Laura,

    You can add

    if (!UserManager.IsCurrentUserInRole("administrators"))
      {
          // then hide the items
      }
      else
      {
          // do not hide anything
      }


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  9. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    06 Jan 2010
    Link to this post
    awesome. works great. thank you!
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    06 Jan 2010
    Link to this post
    Hi Laura,

    Always glad to help to our community.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  11. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    10 Mar 2010
    Link to this post
    Ivan,
    I have the Files displaying correctly using the code you provided. However, when clicking on a folder, I lose the childern in the tree.  Or If I click on PDFS in the tree I lose the folders in the gridview.
    The folder I want to diplay is from the root ~/PDFs  and its children (ex. ~/PDFs/Secure/...  and ~PDFs/Public/...)
    I know I am missing something simple here. My logic may be faulty as I am saying if you are NOT in role administrators and the node text is NOT PDFs ....
    Here is my code from Files.aspx.cs --Thank you.
    public partial class Admin_Files : AdminPage
    {
        public override string MenuItemName
        {
            get { return "files"; }
        }
      
        public override int RightsRequired
        {
            get
            {
                return GlobalRights.ManageFiles;
            }
        }
      
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string path = Request.QueryString.Get("path");
                path = HttpUtility.UrlDecode(path);
                if (!String.IsNullOrEmpty(path))
                {
                    fileManager.SelectedFolder = new System.IO.DirectoryInfo(MapPath("~/" + path));
                }
            }
        }
      
      
    protected override void OnPreRender(EventArgs e)  
        {  
            base.OnPreRender(e);  
            if (fileManager.Mode == FileManagerMode.Upload)  
                mainPanel.Attributes.Add("class", "wrapperUpload");  
            else  
                mainPanel.Attributes.Add("class", "wrapperBrowser");  
                var treeView = FindControlRecursive(foldersNavigation, "foldersTree") as RadTreeView;  
                var radGrid = FindControlRecursive(fileManager, "fileGrid") as RadGrid;
                if (!UserManager.IsCurrentUserInRole("administrators"))  
                    {  
                    RadTreeNode node = null;  
                    foreach (var tnode in treeView.GetAllNodes())  
                    {  
                        if (tnode.Text != "PDFs")  
                        {  
                            node = tnode;  
                            tnode.Visible = false;  
                            radGrid.ItemDataBound += new GridItemEventHandler(radGrid_ItemDataBound); 
       
                        }  
                        else  
                        {  
                            tnode.Visible = true;
                              
                              
                        }  
                    }  
                    while (node.ParentNode != null)  
                    {  
                        node.ParentNode.NavigateUrl = "#";  
                        node = node.ParentNode;  
                        node.Visible = true;  
                    }  
             }  
        
        
        }  
        void radGrid_ItemDataBound(object sender, GridItemEventArgs e)  
        {  
            if ((e.Item.ItemType == GridItemType.Item) || (e.Item.ItemType == GridItemType.AlternatingItem) || (e.Item.ItemType == GridItemType.EditItem))  
            {  
                if (e.Item is GridDataItem)  
                {  
                    GridDataItem dataItem = e.Item as GridDataItem;
                    if (!dataItem["Name"].Text.Equals("PDFs") && !UserManager.IsCurrentUserInRole("administrators"))
                    {
                        dataItem.Display = false;
                   
      
                }  
            }  
        }  
        
        private Control FindControlRecursive(Control root, string id)  
        {  
            if (root.ID == id)  
            {  
                return root;  
            }  
        
            foreach (Control c in root.Controls)  
            {  
                Control t = FindControlRecursive(c, id);  
                if (t != null)  
                {  
                    return t;  
                }  
            }  
        
            return null;  
        }
      
      
    }
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    15 Mar 2010
    Link to this post
    Hello Laura,

    You are explicitly hiding all nodes except PDFs

    if (tnode.Text != "PDFs")
    {
      // here you are hiding all other nodes from the RadTreeView control
    }

    You can make as exception as show below

    if (tnode.Text != "PDFs" && tnode.Level == 1)
    {
      // hide all other nodes
    }

    By doing so if the node text is different from PDFs and node level is "1" we hide the nodes. Since all nodes in PDFs are not level one, directories/files will be visible.

    ProjectName
    |_PDFs
          |_ dir1.

    Greetings,
    Ivan Dimitrov
    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.
  13. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    23 Mar 2010
    Link to this post
    Thanks Ivan, that works great.  Now however, I don't see the contents of the folder if clicked on the tree. I can view the folders and files if I navigate through the grid however, but not if clicking on the tree. Maybe I have the binding incorrect?
    protected override void OnPreRender(EventArgs e)
       {
           base.OnPreRender(e);
           if (fileManager.Mode == FileManagerMode.Upload)
               mainPanel.Attributes.Add("class", "wrapperUpload");
           else
               mainPanel.Attributes.Add("class", "wrapperBrowser");
           var treeView = FindControlRecursive(foldersNavigation, "foldersTree") as RadTreeView;
           var radGrid = FindControlRecursive(fileManager, "fileGrid") as RadGrid;
           if (!UserManager.IsCurrentUserInRole("administrators"))
           {
               RadTreeNode node = null;
               foreach (var tnode in treeView.GetAllNodes())
               {
                   if (tnode.Text != "PDFs" && tnode.Level == 1)
                   {
                       node = tnode;
                       tnode.Visible = false;
                       radGrid.ItemDataBound += new GridItemEventHandler(radGrid_ItemDataBound);
                   }
                    
               }
               while (node.ParentNode != null)
               {
                   node.ParentNode.NavigateUrl = "#";
                   node = node.ParentNode;
                   node.Visible = true;
               }
           }
       }
       void radGrid_ItemDataBound(object sender, GridItemEventArgs e)
       {
           if ((e.Item.ItemType == GridItemType.Item) || (e.Item.ItemType == GridItemType.AlternatingItem) || (e.Item.ItemType == GridItemType.EditItem))
           {
               if (e.Item is GridDataItem)
               {
                   GridDataItem dataItem = e.Item as GridDataItem;
                   if (!dataItem["Name"].Text.Equals("PDFs") && !UserManager.IsCurrentUserInRole("administrators"))
                   {
                       dataItem.Display = false;
                   }
               }
           }
       }
  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    23 Mar 2010
    Link to this post
    Hello Laura,

    The RadTreeView control shows only the files structure. This is the default behavior of the FilesTreeView control.

    Kind regards,
    Ivan Dimitrov
    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.
  15. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    23 Mar 2010
    Link to this post
    Honeslty, that doesn't make sense.  As seen in the attached file, by default, if I click on a folder in the tree structure it displays the content of the folder in the grid. Somehwere by hiding folders by name and by role, they lost their connnection between the two areas.
    Thank you,
  16. Adam
    Adam avatar
    33 posts
    Registered:
    23 Feb 2009
    01 Apr 2010
    Link to this post
    Not too happy about having to touch the CMS core like this, but here was the solution that (finally) worked for me. Now my dinner is cold :(


    using System;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using Telerik.Security;
    using Telerik.Web.UI;
    using Telerik.FileManager;
    using Telerik.Cms.Web;
    using Telerik.Cms.Security;
     
    public partial class Admin_Files : AdminPage
    {
        public override string MenuItemName
        {
            get { return "files"; }
        }
     
        public override int RightsRequired
        {
            get
            {
                return GlobalRights.ManageFiles;
            }
        }
     
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string path = Request.QueryString.Get("path");
                path = HttpUtility.UrlDecode(path);
                if (!String.IsNullOrEmpty(path))
                {
                    fileManager.SelectedFolder = new System.IO.DirectoryInfo(MapPath("~/" + path));
                }
     
            }
        }
     
        private bool IsInValidPath(string targetPath)
        {
            foreach (var allowedFolder in _allowedfolders)
            {
                targetPath = targetPath.ToLower();
                var fullAllowedFolder = Server.MapPath(allowedFolder).ToLower();
                if (targetPath.Contains(fullAllowedFolder))
                    return true;
     
            }
            return false;
        }
     
        private const string MASTERROLE = "administrators";
        private string _serverRoot;
        private static readonly string[] _allowedfolders = new[] { @"/Images", @"/PDFs" };
        private RadTreeView treeView;
     
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            if (fileManager.Mode == FileManagerMode.Upload)
                mainPanel.Attributes.Add("class", "wrapperUpload");
            else
                mainPanel.Attributes.Add("class", "wrapperBrowser");
     
            treeView = FindControlRecursive(foldersNavigation, "foldersTree") as RadTreeView;
     
            var radGrid = FindControlRecursive(fileManager, "fileGrid") as RadGrid;
            if (radGrid != null) radGrid.ItemDataBound += radGrid_ItemDataBound;

            if (!UserManager.IsCurrentUserInRole(MASTERROLE))
            {
                RadTreeNode node = null;
                if (treeView != null)
                    foreach (var tnode in treeView.GetAllNodes())
                    {
                        var fullPath = Server.MapPath(tnode.FullPath.Replace("web_app", ""));
                        if (!IsInValidPath(fullPath))
                        {
                            node = tnode;
                            tnode.Visible = false;
                        }
                        else
                        {
                            tnode.Visible = true;
                        }
                    }
                if (node != null)
                    while (node.ParentNode != null)
                    {
                        node.ParentNode.NavigateUrl = "#";
                        node = node.ParentNode;
                        node.Visible = true;
                    }
            }
     
     
        }
     
        void treeView_NodeClick(object sender, RadTreeNodeEventArgs e)
        {
            if (e.Node.Text == "web_app")
            {
                var treeview = (RadTreeView)sender;
                //treeview.SelectedValue = -1;
            }
        }
     
        private void radGrid_ItemDataBound(object sender, GridItemEventArgs e)
        {
            //var rootPath = treeView.SelectedNode == null ? Server.MapPath(treeView.Nodes[0].FullPath) : Server.MapPath(treeView.SelectedNode.FullPath);
     
            if ((e.Item.ItemType == GridItemType.Item) || (e.Item.ItemType == GridItemType.AlternatingItem) || (e.Item.ItemType == GridItemType.EditItem))
            {
                if (e.Item is GridDataItem)
                {
                    var dataItem = e.Item as GridDataItem;
                    var fullPath = Server.MapPath(dataItem["AbsolutePath"].Text);
                    if (!UserManager.IsCurrentUserInRole(MASTERROLE) && !IsInValidPath(fullPath))
                    {
                        dataItem.Display = false;
                    }
                }
            }
        }
     
        private static Control FindControlRecursive(Control root, string id)
        {
            if (root.ID == id)
            {
                return root;
            }
     
            foreach (Control c in root.Controls)
            {
                var t = FindControlRecursive(c, id);
                if (t != null)
                {
                    return t;
                }
            }
     
            return null;
        }
    }

  17. Tristan
    Tristan avatar
    22 posts
    Registered:
    30 Mar 2009
    19 May 2010
    Link to this post
    can this be implemented for custom controls that call the Filemanager?
  18. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    19 May 2010
    Link to this post
    Hi Tristan,

    You should wrap the Telerik.FileManager.ManageFiles in a custom or user control as it is done in

    Sitefinity/WorkProject3x/Sitefinity/Admin/Files.aspx

    Best wishes,
    Ivan Dimitrov
    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.
  19. Tristan
    Tristan avatar
    22 posts
    Registered:
    30 Mar 2009
    20 May 2010
    Link to this post
    Sorry, but could you give me an example of what you mean.

    I've got a user control with a property that allows the user to select an item from the FileManager when they click the Select button. I just want to be able to restrict the folders the user can see.

    Is this method the best way to combat this or is there a better way buy simply denying permissions to those folders?
  20. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    20 May 2010
    Link to this post
    Hello Tristan,

    You could add the code below in your custom/user control

    <div id="main">
            <div class="in">
                <div runat="server" id="mainPanel">
                    <cc1:ManageFiles Visible="true" runat="server" ID="fileManager">
                        <FilesUploaderTemplate>
                        <div class="ToolsAll">
                            <sfWeb:MessageControl runat="server" ID="message">
                                <ItemTemplate>
                                    <asp:Literal runat="server" ID="messageText"></asp:Literal>
                                </ItemTemplate>
                            </sfWeb:MessageControl>
                            <div class="backWrapp">
                                <asp:LinkButton ID="cancelUploadButton" runat="server" CssClass="actions back"><asp:Literal ID="Literal1" runat="server" Text="CancelAndGoBack"></asp:Literal></asp:LinkButton>
                            </div>
                        </div>
                        <div class="workArea insert">
                            <div class="mainForm">
                            <h3 class="uplHead"><asp:Literal ID="Literal2" runat="server" Text="SelectFilesToUpload"></asp:Literal></h3>
                            <div class="set">
                                <div class="setIn">
                                <telerik:RadUpload
                                ID="uploader"
                                InitialFileInputsCount="10"
                                runat="server"
                                ControlObjectsVisibility="AddButton"
                                Width="400"
                                EnableEmbeddedSkins="false"
                                Skin="Sitefinity"
                                />
                         
                                </div>
                            </div>
                            <div class="bottom"><div><!-- --></div></div>
                            <p class="button_area">
                                <asp:LinkButton ID="uploadButton" runat="server" CssClass="CmsButLeft upldark"><strong class="CmsButRight dark"><asp:Literal ID="Literal3" runat="server" Text="Upload"></asp:Literal></strong></asp:LinkButton>
                                <span><asp:Literal ID="Literal4" runat="server" Text="Or"></asp:Literal></span>
                                <asp:LinkButton ID="cancelUploadButton1" runat="server" cssClass="cmscclcmd" Text="Cancel"></asp:LinkButton>
                            </p>
                            
                            </div>
                 
                    <div class="clear"><!-- --></div>
                    </div>
                        </FilesUploaderTemplate>
                        <FilesGridTemplate>
                        <div class="workArea temp">
                            <div class="mainForm">                 
                            <telerik:RadGrid ID="fileGrid"
                                          runat="server"
                                          BorderWidth="0"
                                          MasterTableView-GridLines="None"
                                          AllowSorting="true"
                                          AllowPaging="true"
                                          PageSize="20"
                                          PagerStyle-Mode="NextPrevAndNumeric"
                                          CellPadding="3"
                                          MasterTableView-EditMode="InPlace"
                                          AllowMultiRowSelection="true"
                                          AllowMultiRowEdit="false"
                                          EnableEmbeddedSkins="false"
                                          Skin="Sitefinity"
                                          >
                              <ClientSettings Resizing-AllowColumnResize="true"
                                              Resizing-AllowRowResize="false"
                                              AllowColumnsReorder="false"
                                              Selecting-AllowRowSelect="true"
                                              ClientEvents-OnRowContextMenu="OnFilesListContextClick"
                                              ClientEvents-OnRowCreated="OnFilesListRowCreated"
                                              Selecting-EnableDragToSelectRows="false"
                                             >
                              </ClientSettings>
                              <MasterTableView AutoGenerateColumns="false">
                                <Columns>
                                    <telerik:GridBoundColumn DataField="Extension"
                                                          UniqueName="Icon"
                                                          HeaderStyle-Width="30"
                                                          HeaderStyle-HorizontalAlign="center"
                                                          ReadOnly="true"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Name"
                                                          UniqueName="Name"
                                                          HeaderText="Name"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Size"
                                                          UniqueName="Size"
                                                          HeaderText="Size"
                                                          HeaderStyle-Width="60"
                                                          ItemStyle-HorizontalAlign="Right"
                                                          ReadOnly="true"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Extension"
                                                          UniqueName="Extension"
                                                          HeaderText="Extension"
                                                          HeaderStyle-Width="60"
                                                          HeaderStyle-HorizontalAlign="right"
                                                          ItemStyle-HorizontalAlign="right"
                                                          ReadOnly="true"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="DateModified"
                                                          UniqueName="DateModified"
                                                          HeaderText="DateModified"
                                                          DataFormatString="DateModifiedFormat"
                                                          HeaderStyle-Width="130"
                                                          HeaderStyle-HorizontalAlign="left"
                                                          ReadOnly="true"></telerik:GridBoundColumn>
                                </Columns>
                              </MasterTableView>
                              <PagerStyle Mode="NumericPages" />
                            </telerik:RadGrid>
                            <telerik:RadContextMenu ID="gridContextMenu"
                                          runat="server"
                                          EnableEmbeddedSkins="false"
                                          Skin="Sitefinity"
                                          >
                                          <Targets>
                                          <telerik:ContextMenuElementTarget ElementID="gridElementTarget" />
                                          </Targets>
                            </telerik:RadContextMenu>
                            </div>
                             
                            <div class="clear"><!-- --></div>
                            </div>
                        </FilesGridTemplate>
                    </cc1:ManageFiles>
                </div>
                </div>
            </div>
        <div id="subnav">
            <div class="in">
            <h2><asp:Literal ID="Literal9" runat="server" Text="SelectAFolder"></asp:Literal></h2>
            <div class="folderTreeViewPlh">
                <cc2:FoldersNavigation id="foldersNavigation" runat="server">
                    <FoldersNavigationTemplate>
                        <telerik:RadTreeView ID="foldersTree"
                                          runat="server"
                                          AutoPostBack="true"                 
                                          EnableDragAndDrop="true"
                                          AllowNodeEditing="true"
                                          SingleExpandPath="true"
                                          EnableDragAndDropBetweenNodes="true"
                                          EnableEmbeddedSkins="false"
                                          Skin="SitefinityFiles"                                     
                                          >
                        </telerik:RadTreeView>
                        <telerik:RadContextMenu ID="foldersContextMenu"
                                          runat="server"
                                          EnableEmbeddedSkins="false"
                                          Skin="Sitefinity" >
                                          <Targets>
                                          <telerik:ContextMenuElementTarget ElementID="foldersElementTarget" />
                                          </Targets>
                            </telerik:RadContextMenu>
                    </FoldersNavigationTemplate>
                </cc2:FoldersNavigation>
            </div>
            </div>
        </div>
        <div class="clear width"><!-- --></div>


    Greetings,
    Ivan Dimitrov
    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.
  21. Satya Vepa
    Satya Vepa avatar
    31 posts
    Registered:
    03 Dec 2009
    17 Jun 2010
    Link to this post
    When I try to use your code to Hide some folders from the user , I get a compilation Error

    Compiler Error Message: CS0103: The name 'UserManager' does not exist in the current context

    Source Error:

    Line 59:         var treeView = FindControlRecursive(foldersNavigation, "foldersTree") as RadTreeView;
    Line 60:         var radGrid = FindControlRecursive(fileManager, "fileGrid") as RadGrid;
    Line 61: if ( ! (UserManager.IsCurrentUserInRole("administrator")))Line 62:         {
    Line 63:             RadTreeNode node = null;

    Can you please let me know, what I am missing.

    I have the following namespaces included

    using

    Telerik.Web.UI;

     

    using

    Telerik.FileManager;

     

    using

    Telerik.Cms.Web.UI;

     

    using

    Telerik.Cms.Web;

     

    using

    Telerik.Cms;

     

    using

    Telerik.Cms.Security;

     



    Thanks
    Satya
  22. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    17 Jun 2010
    Link to this post
    Hello Satya Vepa,

    Try UserManager.DefaultProvider.IsCurrentUserInRole(role name) or create an instance of UserManager.

    Sincerely yours,
    Radoslav Georgiev
    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
  23. bilal
    bilal avatar
    5 posts
    Registered:
    05 Jul 2010
    05 Jul 2010
    Link to this post
    hi
    i want to hide files also, like web.config ....

    any one can help me.

    thanks
    bilal
  24. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    05 Jul 2010
    Link to this post
    Hello bilal,

    You have to subscribe for OnPreRender of the RadGrid control and access the Name of the data item. Then hide the item if your requirements are met.

    sample

    void radGrid_PreRender(object sender, EventArgs e)
     {
        var grid = (Telerik.Web.UI.RadGrid)(sender);
     
        foreach (var itm in grid.Items)
        {
            if (itm is GridDataItem)
            {
                GridDataItem dataItem = itm as GridDataItem;
                if (dataItem["Name"].Text.Equals("Web.config"))
                {
                    dataItem.Visible = false;
                }
            }
     
        }
     }


    Best wishes,
    Ivan Dimitrov
    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
  25. bilal
    bilal avatar
    5 posts
    Registered:
    05 Jul 2010
    05 Jul 2010
    Link to this post
    thanks it's work ;)
  26. Louis Farrell
    Louis Farrell avatar
    37 posts
    Registered:
    24 May 2010
    04 Aug 2010
    Link to this post
    Hey,

    I have pretty much used the code given above, and it nearly works, the only thing is it hides the items in the tree on the left, but the folders and files still remain in the main panel as shown by the screenshot attachment. Is there a way of removing the project name node (boxed in red), so that the first node is the Files node?

    Thanks
  27. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    06 Aug 2010
    Link to this post
    Hello Louis Farrell,

    The last post from Telerik -  7/5/2010 shows how to hide items in the RadGrid. Most probably you are using some other code that does not reflect the explanation in this post.

    Sincerely yours,
    Ivan Dimitrov
    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
Register for webinar
27 posts, 0 answered