New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

File Browser

The following example demonstrates how RadSplitter, RadTreeView, RadGrid and RadMenu can be integrated with the RadAjax framework. The example features the following components:

  • RadSplitter - allows resizing of the content panes

  • RadTreeView - displays the folder structure

  • RadGrid - displays the selected folder contents

  • RadMenu - contains commands

  • RadAjax Manager - manages the Ajax requests

This is a typical example for "File browser" type of application for web.

JavaScript
var loadingPanel = null;
function clientNodeClicked(sender, args) {
  if (!loadingPanel) {
    loadingPanel = $find("AjaxLoadingPanel1");
  }
  loadingPanel.show("RadGrid1"); Directories.GetFilesAndFolders(sender.get_selectedNode().get_value(), updateGrid);
}
function updateGrid(result) {
  var tableView = $find("RadGrid1").get_masterTableView(); tableView.set_dataSource(result); tableView.dataBind();
  if (loadingPanel) {
    loadingPanel.hide("RadGrid1");
  }
}
function rowDataBound(sender, args) {
  var value = args.get_dataItem()["Name"];
  args.get_item().get_cell("Name").innerHTML = String.format('<img src="Img/{0}" align="absmiddle" style="border-width: 0px; vertical-align: middle;margin-right:5px;" alt="icon" />{1}', getImageByFileExt(value), value);
}
function getImageByFileExt(fileName) {
  var image = "File.gif"; var extension = fileName.split(".")[fileName.split(".").length - 1];
  switch (extension) {
    case "dll": case "pdb": image = "File.gif"; break;
    case "cs": image = "cs.gif"; break;
    case "css": image = "css.gif"; break;
    case "html": image = "html.gif"; break;
    case "resx": image = "resx.gif"; break;
    case "vb": image = "vb.gif"; break;
    case "config": case "xml": case "asmx": image = "xml.gif"; break;
    case "ascx": case "aspx": image = "ascx.gif"; break;
    case "gif": case "jpg": image = "gif.gif"; break;
    default: image = "mailfolder.gif"; break;
  }
  return image;
}
Not finding the help you need?
Contact Support