复选框不确定richfaces树的状态

时间:2015-08-10 11:55:57

标签: javascript jquery jsf richfaces

我有richfaces4树,每个节点都有复选框,现在我需要处理复选框状态到

  • 选中(检查标志),
  • 未选中(空),
  • 部分选中(全方位)。

这些状态我需要处理jquery或javascript代码。只要在叶节点上单击任何复选框并更改父节点复选框状态,jquery / javascript方法就会触发。 在我尝试的jquery代码下面,但它仅适用于一个场景,即检查父节点时所有子节点都处于检查状态。



$('input[type="checkbox"]').change(function(e) {
      var checked = $(this).prop("checked"),
      container = $(this).parent().parent().parent().parent();
      container.find('input[type="checkbox"]').prop({
      indeterminate: false,
      checked: checked
 });




JSF代码



<rich:tree id="tree" nodeType="#{node.type}" var="node"
           value="#{treeBean.rootNodes}" toggleType="client"
           selectionType="ajax" toggleNodeEvent="click"
           selectionChangeListener="#{treeBean.selectionChanged}">
  <rich:treeNode type="country" id="country" onclick="" handleClass="even odd">
    <h:selectBooleanCheckbox class="small" value="true" />
    #{node.name}
  </rich:treeNode>
  <rich:treeNode type="company" id="company" handleClass="even odd">
    <h:selectBooleanCheckbox class="small" value="true" />
    #{node.name}
  </rich:treeNode>
  <rich:treeNode type="cd" id="cd">
    <h:selectBooleanCheckbox class="small" handleClass="even odd"/>
    #{node.artist} - #{node.name} - #{node.year}
  </rich:treeNode>
</rich:tree>
&#13;
&#13;
&#13;

要处理不确定状态,我使用下面的代码片段添加jquery以在输入复选框标记后添加span标记

&#13;
&#13;
$.fn.checkbox = function ()	{
		$("input[type=checkbox]").each(function(){
			if(!$(this).next().hasClass('mycheckBox')){
				$(this).after("<span class=mycheckBox></span>")
			}                                                       
		});
	}
&#13;
&#13;
&#13;

通过CSS我正在处理复选框的所有三种状态的样式。

1 个答案:

答案 0 :(得分:0)

the class documentationcustomizing后尝试#!/usr/bin/python import os import hashlib import sys dirname = sys.argv[1] os.chdir(dirname) def dup_fileremove(dir): duplicate = set() os.chdir(dir) path=os.getcwd() print ("The dir is: ", path) for filename in os.listdir(dir): filehash = None filepath=os.path.join(dir, filename) print("Current file path is: ", filepath) if os.path.isdir(filepath): dup_fileremove(filepath) elif os.path.isfile(filepath): filehash =hashlib.md5(file(filepath).read()).hexdigest() if filehash is not None and filehash not in duplicate: duplicate.add(filehash) elif filehash is not None: os.remove(filepath) print("removed : ", filepath) dup_fileremove(dirname)

那就是说,你的问题很难理解,让我们澄清一些观点:

树节点是(取决于样式):

  • 选中(检查标志),
  • 未选中(空),
  • 部分选中(全方位)。

后者是你所称的那个.rf-trn-ico-cst吗?

示例(该图片不是实际的富脸树):

tree checkboxes example

主题编辑后

关于这一点,已经有一个自我回答的主题,但我强烈反对你做同样的https://stackoverflow.com/a/6237015/2375207(ajax查询,只需点击状态)

要阅读的其他主题,未解决但提供成功的线索:

我担心jsf复选框是一个布尔值(只能激活或不激活,不可能获得部分状态),你能告诉我们你的jsf代码吗?

是否可以使用其他库来呈现像https://www.jstree.com/这样的已复选树?

相关问题