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

How to check the rad gridview selected item is file or folder in RAD File explorer

3 Answers 160 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
sandhya
Top achievements
Rank 1
sandhya asked on 24 Jun 2011, 02:12 PM
Hi

This is my requirement

I want to disable the DownloadFile option  if i click on folder and once i select the folder if no records are there in grid that time also it should disable downloadFile option.
If click on file DownloadFile option shuld be enable
All these things happen rad gridview context menu shown and file or folder click.
Note:DownloadFile i added custom button.

i have done like this for if no records are there to display in gridview.But in case of if click on folder i want to disable download option and if i click on file download file option shuld be enable.

 

 

function OnClientShown(oMenu, args) {

 

 

 

var iCount =0;

 

 

 

var deleteMenuItem = oMenu.findItemByValue("Delete");

 

 

 

var radExplorer = $find("<%# radFileExplorer.ClientID %>");

 

 

 

var getGrid = radExplorer.get_grid();

 

 

 

var table = getGrid.get_masterTableView();

 

 

 

var rows = table.get_dataItems();

 

 

 

var downloadFileItem = oMenu.findItemByValue("Download_File");

 

 

 

if (rows.length == 0) {

 

downloadFileItem.set_enabled(

 

false);

 

 

 

 

deleteMenuItem.set_enabled(

 

true);

 

}



Please can u solve this prob.

Thanks
Bhavani.

3 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 28 Jun 2011, 10:30 AM
Hi Sandhya,

You can use RadFileExplorer's get_selectedItem() client-side method to get reference to the currently selected FileExplorerItem, then you can check if this item is file or folder using its isDirectory() method, e.g.:
var radExplorer = $find("<%# radFileExplorer.ClientID %>");
var selectedItem = radExplorer.get_selectedItem();
if(selectedItem.isDirectory())
    alert("Selected Item is a Folder");
elese
    alert("Selected Item is a File");

I hope this helps.

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.

0
Rohan
Top achievements
Rank 1
answered on 23 Jul 2012, 01:33 PM
Hi Dobromir,
thanks for replay ...
How to detect whether folder is empty or not , when user click on the folder  or event(OnGridClientShowing)?
0
Dobromir
Telerik team
answered on 25 Jul 2012, 06:54 PM
Hi Rohan,

I am not quite sure I understand the exact question. Could you please describe in more detail when exactly do you need to check if a folder is empty?

You can check if the currently loaded folder is empty by examining the number of items of the fileList, e.g.:
if(explorer.get_fileList().get_items().length == 0)
    alert("Folder is empty");


Regards,
Dobromir
the Telerik team
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
FileExplorer
Asked by
sandhya
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Rohan
Top achievements
Rank 1
Share this question
or