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

Hide directories in grid

4 Answers 197 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 29 Sep 2009, 07:55 PM
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

4 Answers, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 05 Oct 2009, 10:41 AM
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.
0
David
Top achievements
Rank 1
answered on 12 Oct 2009, 10:21 AM
Hi Fiko,

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

Best regards

Dave
0
Karl Wilkens
Top achievements
Rank 1
answered on 06 Jan 2011, 05:04 PM
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++; 
            } 
        } 
    } 
0
Dobromir
Telerik team
answered on 11 Jan 2011, 05:57 PM
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.
Tags
FileExplorer
Asked by
David
Top achievements
Rank 1
Answers by
Fiko
Telerik team
David
Top achievements
Rank 1
Karl Wilkens
Top achievements
Rank 1
Dobromir
Telerik team
Share this question
or