我知道您可以像这样为所有数据表设置默认值:
jQuery.extend(jQuery.fn.dataTableExt.oSort, {
"num-html-desc": function (a, b) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
});
但我想为 fnInitComplete 设置一个默认函数,它将与/不覆盖其他地方的这个函数一起工作——所以是一个默认值。我怎样才能做到这一点?
最佳答案
您可以添加一个fnInitComplete
默认值:
$.extend($.fn.dataTable.defaults, {
"fnInitComplete": function (oSettings, json) { doSomething(); }
});
为了防止在设置你的数据表时被覆盖,你可以这样做:
$('#myTable').dataTable({
//lots of other properties here
"fnInitComplete": function (oSettings, json) {
$.fn.dataTable.defaults.fnInitComplete(oSettings, json);
doSomethingElse();
}
});
关于javascript - 扩展数据表 "fnInitComplete"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38665841/