【问题标题】:KendoUI grid how to preventDefault during RowselectKendoUI网格如何在Rowselect期间防止Default
【发布时间】:2013-06-11 03:27:15
【问题描述】:

我有一个可选择的 KendoGrid

剃须刀:

@(Html.Kendo().Grid<model>()
        .Selectable()
        .Events(events => events.Change("OnRowSelect"))
)

jQuery:

  function OnRowSelect(e){
    if(!condition) { //if specified condition is true, don't highlight/select the row
      e.preventDefault(); //my function passes the condition and trigger this line
    }
  }

我想做的是在不满足条件时取消/阻止选择。但在上面的代码中,当代码传递给e.preventDefault() 时,它仍然选择行。在我调用OnRowSelect 函数时,似乎已经选择了该行。 Kendo Change 事件之前是否有触发事件?还是我只是错过了什么?

如何防止它选择行?任何帮助,将不胜感激。提前致谢!

【问题讨论】:

    标签: jquery asp.net-mvc kendo-ui kendo-grid preventdefault


    【解决方案1】:

    Change 事件之前不会触发任何事件,但您可以清除您的选择:

    function OnRowSelect(e){
        if(!condition) { 
            e.sender.clearSelection(); 
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-29
      • 1970-01-01
      • 2018-10-05
      • 1970-01-01
      • 2015-03-14
      • 2021-03-16
      • 1970-01-01
      相关资源
      最近更新 更多