我使用的是ColReorder插件。我只想在用户拖放列(在column-reorder事件上)时执行某些操作,而不想在通过API更改列排序(使用colReorder.order() )时执行。
我检查了事件的回调参数,它们在两种情况下看起来都是一样的。是否可以通过API抑制该事件?或任何其他方法来区分这两种情况?
versions:
"datatables": "1.10.13",
"datatables.net-colreorder": "1.3.2",发布于 2017-10-11 17:31:27
您可以在调用colReorder.order()之前注销事件,然后重新注册它。
table.off('column-reorder')
table.colReorder.order(order)
table.on('column-reorder', function(){
// Your code
})或者,您可以只使用布尔值来测试您所处的场景:
var isExplicitCall = false
table.on('column-reorder', function(){
if (!isExplicitCall){
// Your code
}
})
// Then call your reorder
isExplicitCall = true
table.colReorder.order(order)
isExplicitCall = falsehttps://stackoverflow.com/questions/45101785
复制相似问题