Hi !
I want to refresh the TREECONTEXT menu in the RAD FILEEXPLORER. How can I ?
I have a folder lists in the tree context menu , when I delete one of the FOLDER from the context menu, its does not gets deleted & seems to present there but when I REFRESH my whole page then that particular folder gets deleted & not shown in the TREE CONTEXT MENU.
Please help me how to REFRESH the tree context menu or how to do past back to the server on to the click event of the delete button so the folder also gets deleted.
Please help ?
I want to refresh the TREECONTEXT menu in the RAD FILEEXPLORER. How can I ?
I have a folder lists in the tree context menu , when I delete one of the FOLDER from the context menu, its does not gets deleted & seems to present there but when I REFRESH my whole page then that particular folder gets deleted & not shown in the TREE CONTEXT MENU.
Please help me how to REFRESH the tree context menu or how to do past back to the server on to the click event of the delete button so the folder also gets deleted.
Please help ?
4 Answers, 1 is accepted
0
Hello Ajay,
I have already answered your question in this forum thread.
Greetings,
Fiko
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I have already answered your question in this forum thread.
Greetings,
Fiko
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ajay
Top achievements
Rank 2
answered on 20 Oct 2009, 07:07 AM
Hi Fiko !
Thnaks a lot for your valuable comments on my problem , but Iam still not able to find the accurate solution to my problem.
I have implemented the below code on to my .CS file :-
But this doesnt work in my case as Iam able only to refresh the TREE VIEW but the folder that I have ARCHIVED/SELECTED is not getting archived(deleted) form the TREE VIEW.
All I want is NOT TO SHOW THE ARCHIVED FOLDER ON CLICKING ON TO THE ARCHIVE FOLDER CONTEXT BUTTON.
Right now Iam able to REFRESH THE FOLDER but Iam not able to ARCHIVED THE FOLDER.
Please help !
Below is the code Iam attaching :-
While the code in the .CS file will be :--
Please help !!
Ajay Jamwal
Thnaks a lot for your valuable comments on my problem , but Iam still not able to find the accurate solution to my problem.
I have implemented the below code on to my .CS file :-
protected void RadAjaxPanel1_AjaxRequest(object sender, AjaxRequestEventArgs e) |
{ |
// Path to folder ; |
string virtualPathToFolder = e.Argument; |
RefreshFileExplorer(virtualPathToFolder); |
} |
private void RefreshFileExplorer(string VirtualPath) |
{ |
//string dir = VirtualPathUtility.GetDirectory(VirtualPath); |
string script = " var oExplorer = $find('" + DocumentsRadFileExplorer.ClientID + "');" + |
" oExplorer.set_currentDirectory('" + VirtualPath + "');" + |
" oExplorer.refresh();"; |
RadAjaxPanel1.ResponseScripts.Add(script); |
} |
All I want is NOT TO SHOW THE ARCHIVED FOLDER ON CLICKING ON TO THE ARCHIVE FOLDER CONTEXT BUTTON.
Right now Iam able to REFRESH THE FOLDER but Iam not able to ARCHIVED THE FOLDER.
Please help !
Below is the code Iam attaching :-
<asp:Content ID="Content1" ContentPlaceHolderID="MasterContentPlaceHolder" runat="Server"> |
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> |
<script language="javascript" type="text/javascript"> |
function OnClientFileOpen(oExplorer, args) { |
var item = args.get_item(); |
var fileExtension = item.get_extension(); |
// File is a image document, do not open a new window |
args.set_cancel(true); |
// Tell browser to open file directly |
var requestImage = "FileSystemHandler.ashx?path=" + item.get_url(); |
document.location = requestImage; |
//} |
} |
function gridContextMenuClicked(toolbar, args) { |
//var filename = args._targetElement.innerText; |
var buttonValue = args.get_item().get_value(); |
if (buttonValue == "Archive") { |
var oExplorer = $find("<%= DocumentsRadFileExplorer.ClientID %>"); |
var selectedItem = oExplorer.get_selectedItem(); |
if (selectedItem) { |
var itemPath = selectedItem.get_path(); // get the path of the current item |
DoPostBack('Archive', itemPath); |
} |
else { |
alert("Please, select an item"); |
} |
} |
} |
function treeContextMenuClicked(toolbar, args) { |
debugger |
var buttonValue = args.get_menuItem().get_value(); |
var VirtualPath = args.get_node()._properties._data.value; |
if (buttonValue == "Archive") { |
var oExplorer = $find("<%= DocumentsRadFileExplorer.ClientID %>"); |
var oAjaxPanel = $find("<%= RadAjaxPanel1.ClientID %>"); |
var dirPath = oExplorer.get_currentDirectory(); |
if (dirPath) { |
oAjaxPanel.ajaxRequest(dirPath); // Call the RadAjaxPanel1_AjaxRequest function on the server ; |
} |
else { |
alert("Please, select an item"); |
} |
DoPostBack('Archive', VirtualPath); |
} |
} |
function DoPostBack(MenuItem, VirtualPath) { |
__doPostBack(MenuItem, VirtualPath); |
} |
function attachHandlers(explorer, args) { |
//support for tree context menu |
var tree = explorer.get_tree(); |
tree.add_contextMenuItemClicked(treeContextMenuClicked); |
//support for grid context menu |
var gridContextMenu = explorer.get_gridContextMenu(); |
gridContextMenu.add_itemClicked(gridContextMenuClicked); |
} |
function OnClientDelete(oExplorer, args) { |
var isRoot = isRootDir(oExplorer.get_tree(), args.get_path()); |
// Check whether the moved item is a directorty and whether it is the root directory; |
if (args.get_item().isDirectory() && isRoot) { |
alert("You cannot delete the root directory"); |
args.set_cancel(true); |
} |
} |
function OnClientMove(oExplorer, args) { |
var isRoot = isRootDir(oExplorer.get_tree(), args.get_path()); |
// Check whether the moved item is a directorty and whether it is the root directory; |
if (args.get_item().isDirectory() && isRoot) { |
// Check whether this is a renaming ; |
if (isRenaming(args.get_newPath())) {// The renaming operation ; |
alert("You cannot rename the root directory"); |
args.set_cancel(true); |
} |
} |
} |
function isRootDir(oTree, path) { |
var dirForDelete = oTree.findNodeByValue(path); |
if (dirForDelete != null) { |
return dirForDelete.get_level() == 0; |
} |
// Will occurs only when the "path" parameter is not a valid folder path. |
else return false |
} |
function isRenaming(destPath) { |
if (destPath.search("/\//") == -1) { |
return true; |
} |
else { |
return false; |
} |
} |
</script> |
</telerik:RadCodeBlock> |
<style type="text/css"> |
.test_button span span span span |
{ |
background-image: none !important; |
padding-left: 2px !important; |
border: solid 1px grey; |
} |
</style> |
<table width="100%"> |
<tr> |
<td> |
</td> |
</tr> |
<tr> |
<td> |
<telerik:RadFileExplorer runat="server" ID="DocumentsRadFileExplorer" Width="1000px" |
Height="400px" TreePaneWidth="300px" VisibleControls="All" EnableCreateNewFolder="true" |
EnableCopy="true" EnableOpenFile="true" OnClientMove="OnClientMove" OnClientDelete="OnClientDelete" |
OnClientLoad="attachHandlers" OnClientFileOpen="OnClientFileOpen" OnGridPopulated="DocumentsRadFileExplorer_GridPopulated"> |
<Configuration SearchPatterns="*.*" MaxUploadFileSize="10485760"></Configuration> |
</telerik:RadFileExplorer> |
</td> |
</tr> |
<tr> |
<td> |
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" OnAjaxRequest="RadAjaxPanel1_AjaxRequest"> |
<div> |
<span>Selected item :</span> |
<asp:Label ID="Label1" runat="server" Text=""></asp:Label> |
</div> |
</telerik:RadAjaxPanel> |
</td> |
</tr> |
</table> |
</asp:Content> |
using System; |
using System.Collections; |
using System.Data; |
using System.Configuration; |
using System.Drawing; |
using System.Drawing.Imaging; |
using System.IO; |
using System.Web; |
using System.Collections.Generic; |
using Telerik.Web.UI.Widgets; |
using Telerik.Web.UI; |
using System.Data.SqlClient; |
using System.Web.UI.WebControls; |
public partial class DocumentManagementSystem : System.Web.UI.Page |
{ |
protected void Page_Load(object sender, EventArgs e) |
{ |
//DocumentsRadFileExplorer.WindowManager.ReloadOnShow = true; |
GetMappedPath GMP = new GetMappedPath(); |
Dictionary<string, string> mappedPathsInConfigFile = GMP.GetMappingsFromConfigFile(); |
string DocumentPath = ""; |
foreach (KeyValuePair<string, string> mappedPath in mappedPathsInConfigFile) |
{ |
DocumentPath = mappedPath.Value.Replace("/", "\\"); |
} |
string VirtualPath = Request["__EVENTARGUMENT"]; |
string EventTarget = Request["__EVENTTARGET"]; |
if (EventTarget == "Archive") |
{ |
if (VirtualPath.LastIndexOf("/") + 1 == VirtualPath.Length) |
{ |
Archive(VirtualPath, "Folder",DocumentPath ); |
} |
else |
{ |
Archive(VirtualPath, "File",DocumentPath ); |
} |
} |
string[] viewPaths = new string[] { DocumentPath }; |
string[] uploadPaths = new string[] { DocumentPath }; |
string[] deletePaths = new string[] { DocumentPath }; |
DocumentsRadFileExplorer.Configuration.ViewPaths = viewPaths; |
DocumentsRadFileExplorer.Configuration.UploadPaths = uploadPaths; |
DocumentsRadFileExplorer.Configuration.DeletePaths = deletePaths; |
//DocumentsRadFileExplorer.Configuration.SearchPatterns = new string[] { "*.txt" }; |
DocumentsRadFileExplorer.Configuration.ContentProviderTypeName = typeof(CustomFileSystemProvider).AssemblyQualifiedName; |
//RadToolBarButton customButton = new RadToolBarButton("Archive"); |
//customButton.CssClass = "test_button"; |
//customButton.Value = "Archive"; |
//customButton.CommandName = "Archive"; |
//DocumentsRadFileExplorer.ToolBar.Items.Add(customButton); |
//context menu item |
RadMenuItem customMenuOption = new RadMenuItem("Archive"); |
customMenuOption.Value = "Archive"; |
if (DocumentsRadFileExplorer.TreeView.ContextMenus[0].Items.FindItemByText("Archive") == null) |
{ |
DocumentsRadFileExplorer.TreeView.ContextMenus[0].Items.Add(customMenuOption); |
} |
//if you want the custom context menu item to be visible in the grid as well |
DocumentsRadFileExplorer.GridContextMenu.Items.Add(customMenuOption.Clone()); |
//DocumentsRadFileExplorer.ToolBar.ButtonClick += new RadToolBarEventHandler(toolBar_ButtonClick); |
//DocumentsRadFileExplorer.TreeView.ContextMenuItemClick += new RadTreeViewContextMenuEventHandler(TreeView_ContextMenuItemClick); |
//DocumentsRadFileExplorer.GridContextMenu.ItemClick += new RadMenuEventHandler(GridContextMenu_ItemClick); |
//DocumentsRadFileExplorer.GridContextMenu.OnClientItemClicked = "gridContextMenuClicked"; |
if (!IsPostBack) |
{ |
AddCreatedAndModifiedDate(); |
} |
} |
private void AddGridColumn(string name, string uniqueName, bool sortable) |
{ |
//remove first if grid has a column with that name |
//RemoveGridColumn(uniqueName); |
// Add a new column with the specified name |
GridTemplateColumn gridTemplateColumn1 = new GridTemplateColumn(); |
gridTemplateColumn1.HeaderText = name; |
if (sortable) |
gridTemplateColumn1.SortExpression = uniqueName; |
gridTemplateColumn1.UniqueName = uniqueName; |
gridTemplateColumn1.DataField = uniqueName; |
DocumentsRadFileExplorer.Grid.Columns.Add(gridTemplateColumn1); |
} |
private void AddCreatedAndModifiedDate() |
{ |
AddGridColumn("Created Date", "Date", true); |
AddGridColumn("Modified Date", "Date", true); |
} |
private static int DateComparer(FileBrowserItem item1, FileBrowserItem item2) |
{ |
//treat folders separate from files |
DateTime date1 = DateTime.Parse(item1.Attributes["Date"]); |
DateTime date2 = DateTime.Parse(item2.Attributes["Date"]); |
if (item1 is DirectoryItem) |
{ |
if (item2 is DirectoryItem) |
{ |
return DateTime.Compare(date1, date2); |
} |
else |
{ |
return -1; |
} |
} |
else |
{ |
if (item2 is DirectoryItem) |
{ |
return 1; |
} |
else |
{ |
return DateTime.Compare(date1, date2); |
} |
} |
} |
public void Archive(string VirtualPath, string DocType, string DocumentPath) |
{ |
string physicalTargetPath = DocumentPath.Substring(0,DocumentPath.IndexOf("SharedDocument")).Replace("\\","/") + VirtualPath; |
if (DocType == "Folder") |
FileSystem.ArchiveFolder(physicalTargetPath, VirtualPath); |
else |
FileSystem.ArchiveFile(physicalTargetPath, VirtualPath); |
//DocumentsRadFileExplorer.TreeView.DataBind(); |
//DocumentsRadFileExplorer.gRID |
//DocumentsRadFileExplorer.DataBind(); |
//DocumentsRadFileExplorer.TreeView.DataBind(); |
} |
protected void DocumentsRadFileExplorer_GridPopulated(object sender, RadFileExplorerGridEventArgs e) |
{ |
//implement sorting for the custom Date column |
string CreatedDateColumn = e.SortColumnName; |
string ModifiedDatesortingColumn = e.SortColumnName; |
if (CreatedDateColumn == "Created Date") |
{ |
e.List.Sort(DateComparer); |
if (e.SortDirection.IndexOf("DESC") != -1) |
{ |
//reverse order |
e.List.Reverse(); |
} |
} |
if (ModifiedDatesortingColumn == "Modified Date") |
{ |
e.List.Sort(DateComparer); |
if (e.SortDirection.IndexOf("DESC") != -1) |
{ |
//reverse order |
e.List.Reverse(); |
} |
} |
} |
protected void RadAjaxPanel1_AjaxRequest(object sender, AjaxRequestEventArgs e) |
{ |
// Path to folder ; |
string virtualPathToFolder = e.Argument; |
RefreshFileExplorer(virtualPathToFolder); |
} |
private void RefreshFileExplorer(string VirtualPath) |
{ |
//string dir = VirtualPathUtility.GetDirectory(VirtualPath); |
string script = " var oExplorer = $find('" + DocumentsRadFileExplorer.ClientID + "');" + |
" oExplorer.set_currentDirectory('" + VirtualPath + "');" + |
" oExplorer.refresh();"; |
RadAjaxPanel1.ResponseScripts.Add(script); |
} |
} |
Ajay Jamwal
0
Hello Ajay,
I have already answered this question in this forum thread.
Regards,
Fiko
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I have already answered this question in this forum thread.
Regards,
Fiko
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ajay
Top achievements
Rank 2
answered on 23 Oct 2009, 10:54 AM
Hi Fiko !
Thanks a lot .
I have resolved my problem .
Ajay
Thanks a lot .
I have resolved my problem .
Ajay