Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to highlight a jsTree node based on a specific value?

I am using jsTree to build my tree within Oracle APEX v4.2, which all works fine.

What I am after and unsure how to do is, whenever a node in the tree starts with the letter 'S', within the whole tree, I would like to highlight these nodes only with a background colour of say yellow.

Example of result that I after is seen below where the nodes that I want to have a background colour have been marked with a <*>

KING
----------JONES
--------------------SCOTT  <*>
--------------------FORD
------------------------------SMITH  <*>
----------BLAKE
--------------------ALLEN
--------------------WARD
--------------------MARTIN
--------------------TURNER
--------------------JAMES
----------SAM  <*>

Updated

An example of the jsTree, not so much of the example I have above can be found here from another thread that Tom assisted me with, here in SO, i.e. jsTree and Oracle APEX - see here:

Username: apex_demo
Password: demo

http://apex.oracle.com/pls/apex/f?p=69001:2

Based on this example, which is using the same concepts (jsTree), I would expect that only Shelly Noble would be highlighted but if there were other names that started with "S", these would also be highlighted with a background colour of yellow.

like image 381
tonyf Avatar asked Jan 28 '26 03:01

tonyf


1 Answers

Given the HTML structure of the jsTree example in your question, the following should work:

$('#treecontainer a').filter(function() {
    return /^S/i.test($.trim($(this).text()));
}).addClass('highlight'); //amend the class as needed

Example fiddle

like image 191
Rory McCrossan Avatar answered Jan 29 '26 16:01

Rory McCrossan