About Me

Please see my LinkedIn profile for more information about me (http://www.linkedin.com/in/kevinwhitemmlsolutions).

Thursday, May 8, 2008

Controlling editability of individual nodes in an Infragistics WebTree (ASP.NET)

Today I came up against the requirement to control the editability of individual nodes of the WebTree class in the Infragistics ASP.NET library. Examining the Node class (server-side) I saw an Enabled property that looked promising. However setting this to false only sets the appearance client-side to disabled but stills allows the node to be editable. Looking around there is no additional server-side or client-side properities to control the editablity. Therefore I came-up with the following work around (after some brief debugging of the Infragistics client-side code!):

Server-side actions:
  1. Set the Enabled property of any nodes that should not be editable to false.
  2. Hook-up the server-side client-side AfterBeginNodeEdit event e.g. tree.ClientSideEvents.AfterBeginNodeEdit = "tree_afterBeginNodeEdit".

Client-side actions:

  1. Provide an event handler for afterBeginNodeEdit e.g.

function tree_afterBeginNodeEdit(treeId, nodeId)
{
var tree = igtree_getTreeById(treeId);
var node = igtree_getNodeById(nodeId);

if(tree != null && node !=null)
{
if(node.getEnabled() == false)
{
tree.endEdit(true);
}
}
}

The two key points here are:

  • Hook up the AfterBeginNodEdit event. Looking at the documentation the BeforeBeginNodeEdit event would be the logically event to handle. However calling the endEdit method in this event does not work as the edit control does not yet exist (had to debug the Infragistics code to figure this one).
  • Call endEdit which cancels the non-editable node from being edited.

Hope this helps!

No comments: