【问题标题】:Prevent combobox popup when user is type防止用户输入时弹出组合框
【发布时间】:2022-08-04 16:55:19
【问题描述】:

当用户输入文本时,是否可以防止剑道组合框打开它的弹出窗口?我仍然希望允许用户单击箭头按钮。 open 事件可以阻止弹出窗口打开,但无法知道是什么触发了该事件。

$(\"#customers\").kendoComboBox({
    dataTextField: \"ContactName\",
    dataValueField: \"CustomerID\",
    //delay: 999999,  WORKAROUND #1
    //enforceMinLength: true,  WORKAROUND #2
    //minLength: 999999,  WORKAROUND #2
    dataSource: {
        type: \"odata\",
        transport: {
            read: \"...\"
        }
    },
    open: function (e) {
      //Triggered by user click or by user input?
      if (triggeredByUserInput) {
        e.preventDefault();
      }
    }
})

到目前为止,我发现的唯一解决方法是设置很长的delay 或强制使用很长的minLength。虽然它们都有效,但我认为首先解决问题是一种非常奇怪的方法,所以我想知道是否有更具体的解决方案。

    标签: kendo-ui kendo-combobox


    【解决方案1】:

    open 事件仍然提供对原始事件的引用,因此您可以检查用户是否单击了箭头按钮 - example

    open:function(e){
            if(!$(event.target).hasClass("k-button-icon")){
              e.preventDefault();
            }
          }
    

    甚至

     open:function(e){
            if(!(event.type == "click")){
              e.preventDefault();
            }
          }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-04
      • 2017-01-07
      • 2014-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多