扩展数据表”;fnInitComplete”;
Extend Datatables "fnInitComplete"?
我知道你可以为所有数据表设置默认值,如下所示:
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();
}
});