zoukankan      html  css  js  c++  java
  • 解决easyUI下拉控件无法触发onkeydown事件

    实现在combotree下拉控件中按Backspace键清除combotree选中的值

    下面的代码无法获取到键盘事件

    <input class="easyui-combotree" id="tt" name="tt" onkeydown="if(event.keyCode==8) clear()"/>
    

     原因是easyUI重新定义了键盘事件,解决如下:

    $("#tt").combotree({
            url: '../insurance/getcalInsuranceList.do',
            valueField: 'id',
            textField: 'text',
            editable: true,
            lines:true,
            onlyLeafCheck:true,
            panelHeight: 'auto',//高度
            keyHandler: {
              query: function(q,e){
                //q 为输入框的文本值
                if(e.keyCode==8){
                  $("#tt").combotree('clear')
                  $('#tt').combotree('hidePanel');
                }
              }
            },
            onLoadSuccess : function() {
                $("#tt").combotree('tree').tree("collapseAll");//折叠所有节点
            },
            onBeforeSelect: function(node) {
              if (!$(this).tree('isLeaf', node.target)) {
                $(this).tree(node.state === 'closed' ? 'expand' : 'collapse', node.target);  
                return false;
              }
            },
            onClick: function(node) {  
              if (!$(this).tree('isLeaf', node.target)) {  
                  $('#tt').combotree('showPanel');  
              }  
            }  
          });
    

      

  • 相关阅读:
    COJ979 WZJ的数据结构(负二十一)
    COJ980 WZJ的数据结构(负二十)
    奇怪的错误
    COJ883 工艺品
    COJ885 LCS???
    COJ559 回文
    hdu1505(dp求最大子矩阵)
    hdu1506(dp求最大子矩阵)
    hdu2569(递推dp)
    hdu1081(最大子矩阵)
  • 原文地址:https://www.cnblogs.com/lujiulong/p/6869110.html
Copyright © 2011-2022 走看看