国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

老生常談combobox和combotree模糊查詢

2024-05-06 15:18:25
字體:
供稿:網(wǎng)友

First

/**  * combobox和combotree模糊查詢 * combotree 結(jié)果顯示兩級父節(jié)點(手動設(shè)置數(shù)量) * 鍵盤上下鍵選擇葉子節(jié)點 * 鍵盤回車鍵設(shè)置文本的值 */(function(){ //combobox可編輯,自定義模糊查詢  $.fn.combobox.defaults.editable = true;  $.fn.combobox.defaults.filter = function(q, row){  var opts = $(this).combobox('options');  return row[opts.textField].indexOf(q) >= 0;  };  //combotree可編輯,自定義模糊查詢  $.fn.combotree.defaults.editable = true; //選中行索引 var leafBlockIndex=0; //當前選中行索引 var nowLeafBlockIndex=-1; //combotree 組件 var comboTree=null; //葉子節(jié)點DOM Array var leafBlocks=null;; //將所有的結(jié)果葉子節(jié)點放入 DOM Array中 function getDOMArray(data){ comboTree = $(data).combotree('tree'); leafBlocks=new Array(); var leafs = comboTree.tree('getChildren'); for (var i = 0; i < leafs.length; i++) {  var leaf = leafs[i];  var dis =$(leaf.target).css('display')+'';  if('block' == dis){  if(comboTree.tree('isLeaf',leaf.target)){   leafBlocks.push(leaf.target);  }  } };  }; //------------------------------------- $.extend($.fn.combotree.defaults.keyHandler,{  up:function(e){  leafBlockIndex=nowLeafBlockIndex;  leafBlockIndex--;  getDOMArray(this);  if(leafBlockIndex <0){  leafBlockIndex=leafBlocks.length-1;  }  comboTree.tree('select',leafBlocks[leafBlockIndex]);//  easyui 1.3.4版開始可用//  comboTree.tree('scrollTo',leafBlocks[leafBlockIndex]);  nowLeafBlockIndex=leafBlockIndex; }, down:function(e){  leafBlockIndex=nowLeafBlockIndex;  leafBlockIndex++;  getDOMArray(this);  if(leafBlockIndex >= leafBlocks.length){  leafBlockIndex=0;  }  comboTree.tree('select',leafBlocks[leafBlockIndex]);//  easyui 1.3.4版開始可用//  comboTree.tree('scrollTo',leafBlocks[leafBlockIndex]);  nowLeafBlockIndex=leafBlockIndex; }, left: function(e){  console.log('left');//  var val = $(this).combo('getText');//  $(this).combo('setText',val+' '); }, right: function(e){  console.log('right');//  var val = $(this).combo('getText');//  console.log(val);//  $(this).combo('setText',val+' '); }, enter:function(e){  var leaf =$(leafBlocks[nowLeafBlockIndex]);  var value =leaf.children('span').last().text();  $(this).combo('setText',value);  $(this).combo('hidePanel') },  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();   var parent=t.tree('getParent',node.target);   if(parent){   $(parent.target).show();   if(parent){    parent=t.tree('getParent',parent.target);    $(parent.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;   } } });})(jQuery);            
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 浠水县| 新巴尔虎右旗| 文成县| 仁怀市| 呈贡县| 济源市| 阿瓦提县| 河南省| 定襄县| 乌什县| 冕宁县| 广德县| 宁强县| 金山区| 潼关县| 崇义县| 鱼台县| 讷河市| 宜阳县| 萨嘎县| 东台市| 定州市| 青铜峡市| 象州县| 南澳县| 治县。| 始兴县| 乌拉特中旗| 六枝特区| 临邑县| 乌海市| 武宁县| 井陉县| 简阳市| 荥经县| 新晃| 桃园县| 岢岚县| 乡宁县| 葵青区| 天峨县|