How-to: Hide expand button when there are no child nodes existed during WebTreeView’s load-on-demand operation

We have added a new KB article about how to hide expand (+) sign button in certain node that has no child nodes during WebTreeView’s load-on-demand operation.

By default, the expand button will be rendered along with the child nodes regardless whether a node has a child. This behavior sometimes confuses the user as they cannot see which node has child and vice versa.

To perform the above scenario, you can simply add 2 lines of code in InitializeNode server side event, like following:

protected void WebTreeView1_InitializeNode(object sender, WebTreeViewNodeEventArgs e)
{
  
if (e.Node.Nodes.Count == 0)
  
e.Node.ChildNodeExpandable = false;
}

When you run the project, it will look like following:

Hide Expand Button

The sample is available to be downloaded in here.

For more information on this article, you can refer to Intersoft’s support site on the following link:
http://support.intersoftpt.com/KBArticle.aspx?aid=256

Cheers,
Martin Lie.

Leave a Reply