zoukankan      html  css  js  c++  java
  • dtree的自定义select动作

      项目中用到了dtree,别问我为什么用这么古老的插件,因为简单啊orz,文件树的条目不多,detree加载卡顿的问题也不用解决,开森。

      在使用过程中在选择节点后需要自定义一些onclick的动作,本来是打算在html中加script就完了,但是死活实现不了,就只能在原代码上动手了。

      我要实现的是点击一个节点,自动进行搜索和呈现出一个datatable:

    dTree.prototype.s = function(id) {
    
    	if (!this.config.useSelection) return;
    
    	var cn = this.aNodes[id];
    
    	if (cn._hc && !this.config.folderLinks) return;
    
    	if (this.selectedNode != id) {
    
    		if (this.selectedNode || this.selectedNode==0) {
    
    			var eOld = document.getElementById("s" + this.obj + this.selectedNode);
    
    			eOld.className = "node";
    
    		}
    
    		eNew = document.getElementById("s" + this.obj + id);
    
    		eNew.className = "nodeSel";
    
    		this.selectedNode = id;
    
    		if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);
    
    		var father_tag = eNew.innerText.search(/^s/) + 1;
    		if(father_tag){
    			var selected_cancer_name = eNew.innerText.replace(/^s/,"");
    			if(selected_cancer_name != "ALL types"){
    				var result_arr = browse_search(selected_cancer_name,"main_cancer");
    				show_result(result_arr);
    			} else {
    				var result_arr = browse_search(".*","main_cancer");
    				show_result(result_arr);
    			}
    		} else {
    			var result_arr = browse_search(eNew.innerText, "subtype");
    			show_result(result_arr);
    		}
    	}
    
    };
    

      其中father_tag是我用来区分是不是父节点的,因为搜索的条目不同,我用的方法是在父节点前加一个空格和子节点加以区分。

  • 相关阅读:
    window+Apache+php+mysql注意事项
    【转】QRCode二维码的应用心得
    如何创建和配置服务器证书进行SSL Relay
    Citrix 实践中的问题及解决
    web.config中httpRunTime的属性
    [原]IE9 DOM的自定义属性问题
    添加图片到数据库
    Windows server 2008安装企业CA证书服务
    EXTJS Date 的转换格式化字符
    Extjs 4.1 学习笔记(一)(proxy,loader,treestore)
  • 原文地址:https://www.cnblogs.com/wwdPeRl/p/9158469.html
Copyright © 2011-2022 走看看