Hi Telerik,
I am using custom fileexplorer in my application. In this, i am adding some custom columns to the grid some of which are hidden and i could use them as attribute. I could get the attribute for an item in a grid how ever the same is not available for a tree node. This custom attribute are added for both files and directories in respective ResolveDirectory() and ResolveRootDirectoryAsTree() methods.
function OnClientContextMenuShowing
{ var contextMenu = radExplorer.get_tree().get_contextMenus();var menuItemImport = contextMenu[0]._findItemByValue("Import");
menuItemImport.disable();//None of this is making the custom menu item "Import" disabled
//menuItemImport..set_enabled(false);//
}
Regards,
Srikanth
I am using custom fileexplorer in my application. In this, i am adding some custom columns to the grid some of which are hidden and i could use them as attribute. I could get the attribute for an item in a grid how ever the same is not available for a tree node. This custom attribute are added for both files and directories in respective ResolveDirectory() and ResolveRootDirectoryAsTree() methods.
- Is it possible to get the custom attribute of a tree node?
- Is there any event available for treebind at client or server? What i have to do is, on binding, i have to check the custom attribute value and set a different image for the node. This is available with the grid :OnGridRowDataBound(). Do we have similar one for tree?
- How could i disbale the custom menu item in a Tree? s explained in above case, i check the attribute and disable the menu item
function OnClientContextMenuShowing
{ var contextMenu = radExplorer.get_tree().get_contextMenus();var menuItemImport = contextMenu[0]._findItemByValue("Import");
menuItemImport.disable();//None of this is making the custom menu item "Import" disabled
//menuItemImport..set_enabled(false);//
}
Regards,
Srikanth
6 Answers, 1 is accepted
0
Hi Srikanth,
Straight to your questions:
I hope this helps.
All the best,
Dobromir
the Telerik team
Straight to your questions:
- RadTreeView does not offer the same functionality as RadGrid to add attributes but you can achieve this by adding them to the nodes manually using the following code:
protected
override
void
OnInit(EventArgs e)
{
base
.OnInit(e);
RadFileExplorer1.TreeView.Load +=
new
EventHandler(TreeView_Load);
RadFileExplorer1.TreeView.NodeExpand +=
new
RadTreeViewEventHandler(TreeView_NodeExpand);
}
private
void
TreeView_Load(
object
sender, EventArgs e)
{
RadTreeView tree = sender
as
RadTreeView;
AddFileExplorerItemAttributes(tree.Nodes[0],
"10"
);
}
private
void
AddFileExplorerItemAttributes(RadTreeNode node, String value)
{
node.Attributes.Add(
"customAttribute"
, value);
if
(node.Nodes.Count > 0)
{
for
(
int
i = 0; i < node.Nodes.Count; i++)
{
AddFileExplorerItemAttributes(node.Nodes[i], i.ToString());
}
}
}
void
TreeView_NodeExpand(
object
sender, RadTreeNodeEventArgs e)
{
for
(
int
i = 0; i < e.Node.Nodes.Count; i++)
{
RadTreeNode node = e.Node.Nodes[i];
AddFileExplorerItemAttributes(node, (i * 10).ToString());
}
}
var
fileExplorer = $find(
"<% = RadFileExplorer1.ClientID %>"
);
var
treeView = fileExplorer.get_tree();
var
customAttributeValue = treeView.get_selectedNode().get_attributes().getAttribute(
"customAttribute"
);
alert(customAttributeValue);
- RadFileExplorer uses RadTreeView to provide the treeview functionality. RadTreeView offers both server-side and client-side events for nodeDataBound. You can find more information regarding these two methods in the following help articles:
NodeDataBound Server-side Event
OnClientNodeDataBound - I am not quite sure why the provided sample code is not working on your side. In order to disable a context menu item you can use the following approach:
function
OnClientFileExplorerLoad(fileExplorer, args)
{
var
tree = fileExplorer.get_tree();
//get reference to the treeView object
function
contextMenuShownHandler(treeView, args)
{
treeView.get_contextMenus()[0].findItemByText(
"CustomContextMenuItem"
).disable();
//disable the context menu item with text CustomContextMenuItem
}
tree.add_contextMenuShown(contextMenuShownHandler);
//add OnClientContextMenuShown handler
}
I hope this helps.
All the best,
Dobromir
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
srikanth
Top achievements
Rank 1
answered on 02 Sep 2010, 02:56 PM
Hi Telerik,
Let me frame my question like this.
1. In file explorer tree context menu i have a custom menu added. I have to enable it or disable it based on a value. This value is added during to DirectoryItem object when ResolveRootDirectoryAsTree() is called. I am adding this value as explained in the below code
public override DirectoryItem ResolveRootDirectoryAsTree(string path)
{
DirectoryItem returnValue = new DirectoryItem(GetName(path),
GetDirectoryPath(path),
path,
string.Empty,
GetPermissions(path),
null, // The files are added in ResolveDirectory()
GetChildDirectories(path));
return returnValue;
}
private DirectoryItem[] GetChildDirectories(string path)
{
List<DirectoryItem> directories = new List<DirectoryItem>();
try
{
DataRow[] childRows = DataServer.GetChildDirectoryRows(path);
int i = 0;
while (i < childRows.Length)
{
DataRow childRow = childRows[i];
string name = childRow["Name"].ToString();
string itemFullPath = VirtualPathUtility.AppendTrailingSlash(CombinePath(path, name));
DirectoryItem newDirItem = new DirectoryItem(name,
string.Empty,
itemFullPath,
string.Empty,
GetPermissions(itemFullPath),
null, // The files are added in ResolveDirectory()
null // Directories are added in ResolveRootDirectoryAsTree()
);
newDirItem.Attributes.Add("ItemState", childRow["ItemState"].ToString());
directories.Add(newDirItem);
i = i + 1;
}
return directories.ToArray();
}
catch (Exception)
{
}
}
childRow["ItemState"] would give my ItemState value which is added as a property for that particular node item.
So now in client side, i need to get this property when i right click context menu i.e when OnClientContextMenuShown(sender, args) function is called i need to get the attribute "ItemState" of that particular node and based on the value i will enable or diable the context menu item.
The same property for an intem in file explorer grid could be fetched at present how ever i could not fetch the same for tree node item.
2. The Rename context menu on tree node is clicked, file explorer control is getting refreshed but the new name does not get bounded to node immediately. Only after page load, this newly entered name is appreaing. However, renaming an item on grid is immediately reflecting.
3. As explained in #1, i have to disable context menu based on the value. I followed one of your forum which has suggested to use a hidden span and append it to item name property and onclient side get this value using javascript substring operation. This is working fine where i could get the value and disable the context menu based on the value. But now the problem is rename. When i try to rename such nodes, it shows the folder name along with that hidden span string. How do i reset the node name to its older value by strippping its hidden text? I have got the the original text of the node and now i need to set this to the node which is in rename(edit) state???
My node name with hidden string is : Images2 <span class='hiddenSpan'>Importing</span>
Original string is : Images2
4. What does this api do ?
radExplorer.get_tree().get_selectedNode()._getControl()._editNodeText(f,h,e)
What is f and h and e stand for?
As explained in #3, can i use this API to set the node name?
5. Last time i spoke about non-alignment of page slider wehn splitter is dragged in file explorer in IE but some how screen shot of the same was not uploded in the thread. Along with this, one more issue what i found is that the pagination slider control in file explorer, does not align at its place. It moves below its position on load some times and some othe times realign properly.
Regards,
Srikanth
Let me frame my question like this.
1. In file explorer tree context menu i have a custom menu added. I have to enable it or disable it based on a value. This value is added during to DirectoryItem object when ResolveRootDirectoryAsTree() is called. I am adding this value as explained in the below code
public override DirectoryItem ResolveRootDirectoryAsTree(string path)
{
DirectoryItem returnValue = new DirectoryItem(GetName(path),
GetDirectoryPath(path),
path,
string.Empty,
GetPermissions(path),
null, // The files are added in ResolveDirectory()
GetChildDirectories(path));
return returnValue;
}
private DirectoryItem[] GetChildDirectories(string path)
{
List<DirectoryItem> directories = new List<DirectoryItem>();
try
{
DataRow[] childRows = DataServer.GetChildDirectoryRows(path);
int i = 0;
while (i < childRows.Length)
{
DataRow childRow = childRows[i];
string name = childRow["Name"].ToString();
string itemFullPath = VirtualPathUtility.AppendTrailingSlash(CombinePath(path, name));
DirectoryItem newDirItem = new DirectoryItem(name,
string.Empty,
itemFullPath,
string.Empty,
GetPermissions(itemFullPath),
null, // The files are added in ResolveDirectory()
null // Directories are added in ResolveRootDirectoryAsTree()
);
newDirItem.Attributes.Add("ItemState", childRow["ItemState"].ToString());
directories.Add(newDirItem);
i = i + 1;
}
return directories.ToArray();
}
catch (Exception)
{
}
}
childRow["ItemState"] would give my ItemState value which is added as a property for that particular node item.
So now in client side, i need to get this property when i right click context menu i.e when OnClientContextMenuShown(sender, args) function is called i need to get the attribute "ItemState" of that particular node and based on the value i will enable or diable the context menu item.
The same property for an intem in file explorer grid could be fetched at present how ever i could not fetch the same for tree node item.
2. The Rename context menu on tree node is clicked, file explorer control is getting refreshed but the new name does not get bounded to node immediately. Only after page load, this newly entered name is appreaing. However, renaming an item on grid is immediately reflecting.
3. As explained in #1, i have to disable context menu based on the value. I followed one of your forum which has suggested to use a hidden span and append it to item name property and onclient side get this value using javascript substring operation. This is working fine where i could get the value and disable the context menu based on the value. But now the problem is rename. When i try to rename such nodes, it shows the folder name along with that hidden span string. How do i reset the node name to its older value by strippping its hidden text? I have got the the original text of the node and now i need to set this to the node which is in rename(edit) state???
My node name with hidden string is : Images2 <span class='hiddenSpan'>Importing</span>
Original string is : Images2
4. What does this api do ?
radExplorer.get_tree().get_selectedNode()._getControl()._editNodeText(f,h,e)
What is f and h and e stand for?
As explained in #3, can i use this API to set the node name?
5. Last time i spoke about non-alignment of page slider wehn splitter is dragged in file explorer in IE but some how screen shot of the same was not uploded in the thread. Along with this, one more issue what i found is that the pagination slider control in file explorer, does not align at its place. It moves below its position on load some times and some othe times realign properly.
Regards,
Srikanth
0
Hi Srikanth,
Please accept my sincere apologies for the delayed answer.
Now to your questions:
All the best,
Dobromir
the Telerik team
Please accept my sincere apologies for the delayed answer.
Now to your questions:
- As I said in my previous post RadFileExplorer does not provide the required functionality out of the box, adding attributes to the items in the content provider does not pass them to the RadTreeView's nodes. For your convenience I have prepared a sample page implementing this functionality. Please find it attached.
- I am not quite sure I understand this question. Could you please describe in more details what you are trying to achieve?
- This functionality is implemented in the attached sample page using the approach that I provided in my previous answer.
- _editNodeText(node, text, shouldPostback) is the private method responsible for the node rename. Since this is a private method it is highly not recommended to be used, because it may be changed in a future releases of RadControls for ASP.NET AJAX. You can find the corresponding public methods in the client-side API documentation.
- We are aware of this issue and working on fixing it. Unfortunately, I am unable to provide a suitable workaround for the moment. Please excuse us for the inconvenience.
All the best,
Dobromir
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
srikanth
Top achievements
Rank 1
answered on 14 Sep 2010, 10:57 AM
Hi Telerik,
Here are my new questions:
Regards,
Srikanth
Here are my new questions:
- How to disable delete icon on the rad tool bar of fileexplorer for folders? I need this button to be enabled only when a file is selected. This delete should operate only on files shown in grid.
- How can i disable deletion of root level nodes? I need to diable delete context menu as well as button in toolbar for such nodes?
- As explained in the previous post #2, when you rename a folder, the new name is not shown on it immediately. After page refresh /reload only the new folder name is displayed.
- I want to display the processing image in the middle of RadGird (or any contril in general) in my application. However i could not achieve the same. The image is displayed at the top of grid. I need exactly same as it is available in fileexplorer whenever the control is refreshed/reloaded with data. I have followed some demos available online but could not acheive it.
Regards,
Srikanth
0
srikanth
Top achievements
Rank 1
answered on 16 Sep 2010, 04:22 PM
Hi telerik,
In my previous post i had asked about disabling Delete button for folders. I could some how get this working using client side events of folderLoaded event however if there is any other simple method available that would be great.
Now what i have seen as a big issue is sorting of custom columns. In file explorer, i have added certain custom columns.What i was assuming is that the control will take care of sorting of such columns but it doesn't. When i click on such columns it just shows up and down arrow but nothing gets sorted. Am i missing anything here or does the control only supports sorting of Default columns?? I have even set the RadFileExplorer1.Grid.AllowSorting = True in page load.
Thecustom columns are
What is the work around for this? Should it be done in the code behind? Also what i think is currently sorting is going to happen on entire data even though we have enabled paging and page size is set as 50. Is there custom pagination based on say start and end index available?
Please reply ASAP.
Please note that our web application is using custom DBContentProvider.
In my previous post i had asked about disabling Delete button for folders. I could some how get this working using client side events of folderLoaded event however if there is any other simple method available that would be great.
Now what i have seen as a big issue is sorting of custom columns. In file explorer, i have added certain custom columns.What i was assuming is that the control will take care of sorting of such columns but it doesn't. When i click on such columns it just shows up and down arrow but nothing gets sorted. Am i missing anything here or does the control only supports sorting of Default columns?? I have even set the RadFileExplorer1.Grid.AllowSorting = True in page load.
Thecustom columns are
- LastModifiedDate - which is a datetime field
- FileType - string
What is the work around for this? Should it be done in the code behind? Also what i think is currently sorting is going to happen on entire data even though we have enabled paging and page size is set as 50. Is there custom pagination based on say start and end index available?
Please reply ASAP.
Please note that our web application is using custom DBContentProvider.
0
Hi Srikanth,
Straight to your questions:
For your convenience I have attached a working project to this thread.
I hope this helps.
Greetings,
Fiko
the Telerik team
Straight to your questions:
- You can achieve the required functionality by attaching a handler to the RadFileExplorer's OnClientItemSelected client-side event. Here is a sample function that implements the required functionality:
function
explorerItemSelected(oExplorer, args)
{
var
item = args.get_item();
//get reference to the selected Item
var
toolBar = oExplorer.get_toolbar();
//get reference to the ToolBar
var
deleteButton = toolBar.findItemByValue(
"Delete"
);
//get reference to the delete button
if
(item.isDirectory())
//check if the selected item is file or folder
deleteButton.disable();
else
deleteButton.enable();
}
- By design, RadFileExplorer does not allow users to delete Root level folder.
- There was a problem with the custom DBContentProvider provided in the Live Demos. If you are using this provider could you please verify that you are using its latest version (you can find the code in this Code Library). If this is not the case, could you please provide your implementation so we can investigate it further?
- I am not quite sure I understand what exactly you are trying to achieve. Could you please provide me more information about your setup? Once I have a better view over your exact configuration, I can give you a working solution of the problem that you experience.
For your convenience I have attached a working project to this thread.
I hope this helps.
Greetings,
Fiko
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items