Hide directories in grid

5 posts, 0 answers
  1. David
    David  avatar
    12 posts
    Member since:
    Aug 2012

    Posted 29 Sep 2009 Link to this post

    Hi,

    is there a possibility how I can hide directories displayed in right side (grid) of fileexplorer ?

    I just want to display directories on left side.

    I tried this:

     

    function OnFileExplorerClientLoad(oExplorer, args) {
    var masterTable = oExplorer.get_grid().get_masterTableView();

    var items = masterTable.get_dataItems();

    for (var i = 0; i < items.length; i++) {

    var row = items[i];

    row.visible = row.isDirectory();
    }

    Thank you

  2. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 05 Oct 2009 Link to this post

    Hi David ,

    In your case I recommend you use the following server-side approach :

    protected void Page_Load(object sender, EventArgs e) 
        RadFileExplorer1.ExplorerPopulated += new RadFileExplorerGridEventHandler(RadFileExplorer1_ExplorerPopulated); 
     
    void RadFileExplorer1_ExplorerPopulated(object sender, RadFileExplorerPopulatedEventArgs e) 
        List<FileBrowserItem> items = e.List; 
        bool isGridPopulated = items.Exists(it => (it is FileItem)); 
        if (isGridPopulated) 
        { 
            int i = 0
            while (i < items.Count
            { 
                if (items[i] is DirectoryItem) 
                { 
                    items.Remove(items[i]); 
                } 
                else 
                { 
                    i++; 
                } 
            } 
        } 

    The ExplorerPopulated event is fired for both TreeView and Grid controls. By default, the TreeView does not contain FileItem and for the time being I recommend you use the highlighted code in order to determine the  currently populated control. Please note that the solution will work only if the folders contain files, not only child folders.
    We also plan to add a new property to the RadFileExplorerPopulatedEventArgs that will show the populated control.

    I hope this helps.

    Kind regards,
    Fiko
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. David
    David  avatar
    12 posts
    Member since:
    Aug 2012

    Posted 12 Oct 2009 Link to this post

    Hi Fiko,

    thank you very much for your help. I'll test it today.

    Best regards

    Dave
  5. Karl Wilkens
    Karl Wilkens avatar
    206 posts
    Member since:
    Oct 2012

    Posted 06 Jan 2011 Link to this post

    Is it possible to do the inverse and hide certain folders only in the left hand folder view?

    I tried this sample http://www.telerik.com/support/kb/aspnet-ajax/fileexplorer/hide-files-and-folders.aspx but I dont want to filter the right hand pane - if we dont filter a folder, its files should be available. I tried modifying this code several ways but could not figure out how to achieve this result. Any help appreciated?
                    i++; 
                } 
            } 
        } 
  6. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 11 Jan 2011 Link to this post

    Hi David ,

    The required functionality is not supported by RadFileExplorer out-of-the-box.

    Hiding folders from the TreeView only can be achieved using the above mentioned approach (hiding the items during the ExplorerPopulated event of RadFileExplorer.
    protected void Page_Load(object sender, EventArgs e)
    {
        RadFileExplorer1.ExplorerPopulated += new RadFileExplorerGridEventHandler(RadFileExplorer1_ExplorerPopulated);
    }
     
    void RadFileExplorer1_ExplorerPopulated(object sender, RadFileExplorerPopulatedEventArgs e)
    {
        List<FileBrowserItem> items = e.List;
         
        if (e.ControlName == "tree")
        {
            int i = 0;
            while (i < items.Count)
            {
                if (items[i] is DirectoryItem)
                {
                    items.Remove(items[i]);
                }
                else
                {
                    i++;
                }
            }
        }
    }

    However, the hidden folders will not be accessible because of how RadFileExplorer is designed. The logic behind the RadFileExplorer control, however, expects to find a folder (with the same path as shown in the Grid) in the TreeView. Such a folder, however, does not exists and this is why the operation is aborted .You can override this behavior by overriding a method in the RadFileExplorer's client-side API:
    <script type="text/javascript">
        Telerik.Web.UI.RadFileExplorer.prototype._gridOpenFolder = function (path)
        {
            //open a subfolder in the grid
            var tree = this.get_tree();
            if (tree != null)
            {
                //Expand the node in the treeview that is being doubleclicked in the grid
                var nodeToExpand = tree.findNodeByValue(path);
                if (nodeToExpand)
                {
                    nodeToExpand.select();
                    nodeToExpand.expand();
                    //populate the grid
                }
     
                this._makeGridCallback(path);
            }
        };
     
    </script>

    You can add this code to the page that hosts RadFileExplorer and then you will be able to open the folder. Please note that, however, _gridOpenFolder is a private method and such an override is not a safe operation because we can change its behavior in further releases. This is why, I do not recommend you to do this.

    Kind regards,
    Dobromir
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017