简体   繁体   English

如何根据特定值突出显示jsTree节点?

[英]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. 我正在使用jsTree在Oracle APEX v4.2中构建我的树,一切正常。

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. 我所追求的并且不确定如何做,每当树中的节点以字母“S”开头时,在整个树中,我想突出显示这些节点,只有背景颜色为黄色。

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, ie jsTree and Oracle APEX - see here: jsTree的一个例子,不是我上面的例子,可以在Tom帮助我的另一个线程中找到,这里是SO,即jsTree和Oracle APEX - 请看这里:

Username: apex_demo
Password: demo

http://apex.oracle.com/pls/apex/f?p=69001:2 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. 基于这个使用相同概念(jsTree)的例子,我希望只有Shelly Noble会被突出显示,但是如果有其他名称以“S”开头,那么这些也会以背景颜色黄色突出显示。

Given the HTML structure of the jsTree example in your question, the following should work: 给出问题中jsTree示例的HTML结构,以下内容应该有效:

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

Example fiddle 示例小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM