4 Replies Latest reply: Feb 6, 2013 5:11 AM by Mahmoud_Rabie RSS

    Change color of nodes in Tree based on regular expression

    Mahmoud_Rabie
      Dear Experts,

      Given:
      The sample:
      http://apex.oracle.com/pls/apex/f?p=53647:5
      test/test

      Workspace information
      Workspace : ralab
      user : test
      password : test
      application : Sample Trees
      page : 5

      Required
      I can change node color using jQuery contains() selector based on a value e.g. Project
      apex.jQuery("#eba_demo_tree").find("a:contains('Project')").css("color","red");
      Now, the question :
      How to update the jQuery code to do change the node based on a regular expression like
      ^[P]
      or in other words for all nodes starts with P, the color should be changed to red?

      Best Regards
      Mahmoud
        • 1. Re: Change color of nodes in Tree based on regular expression
          fac586
          Mahmoud_Rabie wrote:
          Dear Experts,

          Given:
          The sample:
          http://apex.oracle.com/pls/apex/f?p=53647:5
          test/test

          Workspace information
          Workspace : ralab
          user : test
          password : test
          application : Sample Trees
          page : 5

          Required
          I can change node color using jQuery contains() selector based on a value e.g. Project
          apex.jQuery("#eba_demo_tree").find("a:contains('Project')").css("color","red");
          Now, the question how to update the jQuery code to do change the node based on a regular expression like
          ^[P]
          or in other words for all nodes starts with P, the color should be changed to red
          Don't think I can recall anyone posting a thread so they can answer another one (and demand points for doing so) before.

          If anyone's up for it, just answer the original: +{thread:id=2491175}+
          • 2. Re: Change color of nodes in Tree based on regular expression
            Mahmoud_Rabie
            Hi Paul,

            I agree with you we should concentrate. However, to be fair, you should read the sequence of replies in that thread. It is started by request then satisfied as the requester said
            yOUR SAMPLE IS exactly what iam looking for can you pls take a looking at the sample i provided in my workspace.
            after that the requester said
            under names lets say i want to change background color if the name start with "M%" so Martin & Miller should be different,
            I know it is done by regular expressions but I don't know how to customize the jquery selector to do so

            I asked him to close the thread (without demanding points :) to make you happy)

            I would appreciate your help in this thread

            Regards
            Mahmoud
            • 3. Re: Change color of nodes in Tree based on regular expression
              Tom Petrus
              $("#eba_demo_tree a").filter(function(index){
                 var lRegExp = /^m/i; //or new RegExp('^m', 'i');
                 //trim to get rid of leading space due to space in encapsulated ins-element
                 return lRegExp.test($(this).text().trim());
              });
              http://api.jquery.com/filter/
              http://www.w3schools.com/jsref/jsref_obj_regexp.asp
              http://www.regular-expressions.info/javascript.html