In RAD File explorer grid context menu if i click on download it should download the file.How can we achieve this task.
Is there any demo example with code .please can you share it me..
How to get the physical path from server side.?
I added custom download file button in grid context menu.
This is my code:
Client side:
--------------
function DownloadFileWindow(oGridMenu, args) {
var domElem = args.get_targetElement();
var text = $telerik.$(domElem).text();
//var isFolder = text.indexOf(".") == -1;
var gridContextMenuItems = oGridMenu.get_allItems();
for (var i = 0; i < gridContextMenuItems.length; i++) {
var menuItem = gridContextMenuItems[i];
if (menuItem.get_value() == "Download_File") {
OnClientFileOpen(sender, args)
__doPostBack(
"download");
}
}
}
Server side:
radFileExplorer.GridContextMenu.OnClientItemClicked = "DownloadFileWindow";
I am calling my function like this
string userSelection = Request.Params.Get("__EVENTTARGET");
if (userSelection == "download")
{
DownLoadFile();
}
private
void DownLoadFile()
{
string TargetFile = here i need physical path of the file
//radFileExplorer.TreeView.SelectedNode.GetFullPath("/");//radFileExplorer.Configuration.ViewPaths;
System.IO.
FileInfo file = new System.IO.FileInfo(TargetFile);
//-- if the file exists on the server
//set appropriate headers
if (file.Exists)
{
FileStream liveStream = new FileStream(TargetFile, FileMode.Open, FileAccess.Read);
byte[] buffer = new byte[Convert.ToInt32(liveStream.Length) + 1];
liveStream.Read(buffer, 0,
Convert.ToInt32(liveStream.Length));
liveStream.Close();
Response.ClearHeaders();
Response.ClearContent();
Response.Clear();
Response.ContentType =
"application/octet-stream";
Response.AddHeader(
"Content-Length", buffer.Length.ToString());
Response.AddHeader(
"Content-Disposition", "attachment; filename=" + file.Name);
Response.BinaryWrite(buffer);
}
}