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

RadFileExplorer Custom Context Menu Item Progress Indicator

5 Answers 146 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 19 Apr 2012, 03:43 PM
I'm posting this to see if anyone has accomplished this.  I have been trying for a couple of days and am ready to give up.
I have a RadFileExplorer and have added a custom context menu item called Download.  This button action will Download a file or folder from the server to the client computer.  If the download is a folder I zip up the contents of that folder first and then present the download using Response.TransmitFile.  Pretty straight forward.  The problem comes that when you select a folder that is large the zip process may take a while.  I want to notify the client of the progress.  I am already using the RadProgressArea for the Upload control of the RadFileExplorer so I have AllowCustomProgress set to false in the web.config so that it won't show up when selecting the Download. 

Below is my code for the download click client event:

 

function extendedFileExplorer_onGridContextItemClicked(oGridMenu, args) {

 

 

var menuItemText = args.get_item().get_text();

 

switch (menuItemText) {

 

case "Download":

extendedFileExplorer_sendItemsPathsToServer();

 

break;

 

case "Share":

 

var fExplorer = $find("<%= RadFileExplorer1.ClientID %>");

 

var item = fExplorer.get_selectedItem();

 

var owindow = window.radopen("ShareResource.aspx?path=" + item.get_path(), "ShareResourceWindow");

 

return false;

 

break;

}

}

 

function extendedFileExplorer_sendItemsPathsToServer() {

 

var oExplorer = $find("<%= RadFileExplorer1.ClientID %>"); // Find the RadFileExplorer ;

 

var selectedItems = oExplorer.get_selectedItems(); // Retrieve the selected items ;

 

var selectedItemsPaths = extendedFileExplorer_combinePathsInAString(selectedItems); // Get the paths as a string in specific format ;

 

var hiddenField = $get("<%= ctlHiddenField.ClientID %>"); // Find the hiddenField

hiddenField.value = selectedItemsPaths;

__doPostBack(

 

"<%= btnDownload.UniqueID %>", ""); // Call the 'btnDownload_Click' function on the server ;

}

 

function extendedFileExplorer_combinePathsInAString(arrayOfSelectedItems) {

 

var itemPaths = new Array();

 

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

 

// Pass all the selected paths ;

itemPaths.push(arrayOfSelectedItems[i].get_path());

}

 

// Return a string that contains the paths ;

 

return itemPaths.join("|");

}


So this fires off the btnDownload button click event on the server.  From there I am using the DotNetZip library which has tons of progress feedback events that I can access.  So I need to notify the client of some of those events like which file is compressing and total percentage completed.  Has anyone ever tried something like this and made it work?

Thanks,
Adam

5 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 24 Apr 2012, 01:16 PM
Hi Adam,

Unfortunately, I will have to disappoint you, it is not possible to toggle the value of this setting dynamically, thus you cannot enable custom progress only for specific cases.

Kind 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.
0
Rohan
Top achievements
Rank 1
answered on 29 May 2012, 09:44 AM
Hi all
 I am implementing the custom content provider for file explore  using SQL. i want get the file id on onGridContextItemClicked .
how can i get ....
0
Dobromir
Telerik team
answered on 29 May 2012, 11:17 AM
Hi Rohan,

In order to pass specific value for each item listed in the explorer, I would suggest you to add it as a custom attribute to the FileItem / DirectoryItem in the ResloveDirecotury() method of the content provider. Please take a look at the following live demo using this approach:
FileExplorer / Add custom columns

Then you can access the custom attribute in the following manner:
explorer.get_grid().get_selectedItems()[0].get_dataItem().Attributes['customAttribute'];


Kind 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.
0
Rohan
Top achievements
Rank 1
answered on 12 Jul 2012, 11:14 AM
Hi all ,
I want to get file or folder  name on  onGridContextItemClicked at client side ,
I am able to get custom attributes by using this code
explorer.get_grid().get_selectedItems()[0].get_dataItem().Attributes['customAttribute'];
 but not able to get file or folder name ,it gives undefined ......
how can i get the file name at client side using onGridContextItemClicked  event ....
0
Dobromir
Telerik team
answered on 17 Jul 2012, 07:18 AM
Hi Rohan,

You can get the name of the File / Directory related to the context menu through the selectedItem's dataItem, e.g.:
function explorerLoad(explorer){
    explorer.get_gridContextMenu().add_itemClicked(function(sender, args){
        alert(explorer.get_grid().get_selectedItems()[0].get_dataItem().Name);
    })
}


All the best,
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
Adam
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Rohan
Top achievements
Rank 1
Share this question
or