easyui easyui-combotree 模糊查询

<input id="select" type="text" class="easyui-combotree" data-options=" 
	    url: 'url地址',
	    method:'get',
	    checkbox:true,
	    lines:true,
	    multiple:true,
	    panelHeight:150,
            panelWidth:250,
	    clickNodeForSpan:true, 
	    
            editable : true,
            onLoadSuccess: function (row, data) {
                    //$('this').combotree('tree').tree("collapseAll");     
                     $('this').combotree('tree').tree("expandAll");  //这个必须写,否则查询不正确    
                }
            keyHandler : {
                query : function(q) {
		    var t = $(this).combotree('tree');  
		    var nodes = t.tree('getChildren');  
		    for(var i=0; i<nodes.length; i++){  
		        var node = nodes[i];  
		        if (node.text.indexOf(q) >= 0){  
                            $(node.target).show();  
		        } else {  
                            $(node.target).hide();  
		        }  
		        var opts = $(this).combotree('options');  
		        if (!opts.hasSetEvents){  
                        opts.hasSetEvents = true;  
                        var onShowPanel = opts.onShowPanel;  
                        opts.onShowPanel = function(){  
                        var nodes = t.tree('getChildren');  
                        for(var i=0; i<nodes.length; i++){  
                            $(nodes[i].target).show();  
                        }  
                        onShowPanel.call(this);  
                    };  
                    $(this).combo('options').onShowPanel = opts.onShowPanel;  
	        }  
	        }
	   }
     " />
posted @ 2019-12-25 17:29  小海葵  阅读(772)  评论(0编辑  收藏  举报