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