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
440
First item clicked retains invalid CSS
posted

Since upgrading from 12.1.20121.1005 to 12.1.20121.2178 I have a problem with the first node clicked in the treeview retaining the active styling after I click on another node. See here for an example of the problem. The problem disappears when I click on any object outside the treeview.

My page is complicated by the fact that the WebDataTree is created as a template within a WebExplorerBar. Looking at the CSS, I think the first item clicked is being styled with the WebExplorerBar active item style.

I have created an example project that replicates the problem and attached it below.

Any help would be appreciated. I upgraded in the hope this would fix another bug, which it hasn't, just introduced this! Great!!

WebApplication1.zip
Parents
  • 440
    posted

    As an update, I have found a solution myself which I have posted below if anyone else has the same issue. However, it overrides my style sheets, and relies on the WebDataTree element structure remaining consistent, so if the Infragistics staff or anyone else can some up with a more elegant solution I would appreciate it.

    My solution was to add the following script, the treeViewItemClick function being called from the WebDataTree item click event;

    function treeViewItemClick(sender, args) {
      var selectedNode = args.getNode();
      if (selectedNode != null) {
        var nodes = sender.getNodes();
        for (var i = 0; i < nodes.get_length(); i++) {
          var node = nodes.getNode(i);
          clearNodeBackground(node, selectedNode);
        }
      }
    }

    function clearNodeBackground(node, selectedNode) {
      if (node != null) {
        if (selectedNode.get_valueString() != node.get_valueString()) {
          node.get_element().childNodes[2].style.backgroundColor = "White";
        } else {
          node.get_element().childNodes[2].style.backgroundColor = "#FFE474";
        }
        // Now check if it has any children, do the same for each if so
        if (node.hasChildren()) {
          for (var i = 0; i < node.get_childrenCount(); i++) {
            clearNodeBackground(node.get_childNode(i), selectedNode);
          }
        }
      }
    }

Reply Children
No Data