Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
175
Trimming a string in the WebTree control
posted

Hello everyone,

 I have a problem in trimming the values of the nodes in the WebTree control. What I want to do is when the length of a string in a node surpasses a certain value (lets say 10), I want to display only the first 10 characters of that string.

Has anyone tried this before?

C.

Parents
No Data
Reply
  • 330
    posted

    Try using a derived tree, like this (probably not the most efficient way, but hey):-

      public class myTree : Infragistics.WebUI.UltraWebNavigator.UltraWebTree
      {
        public override void OnNodeExpand(Node node)
        {
          base.OnNodeExpand(node);
         
          foreach (Node n in node.Nodes)
            NodeTrimmer(n);
        }
     
        // in case using ManualSmartCallbacks
        public override void OnDemandLoad(Node node)
        {
          base.OnDemandLoad(node);
         
          foreach (Node n in node.Nodes)
            NodeTrimmer(n);
        }
     
        private void NodeTrimmer(Node node)
        {
          // Trim node text
          if (node.Text.Length > 10)
            node.Text = node.Text.Substring(0, 10);
     
          // recurse children
          foreach (Node child in node.Nodes)
            NodeTrimmer(child);
        }
      } 

     

Children
No Data