gpt4 book ai didi

javascript - jQuery DataTable : Callback function(fnUpdate, fnCreatedCell 等)如果 mData 为空则不起作用

转载 作者:行者123 更新时间:2023-11-29 19:45:11 25 4
gpt4 key购买 nike

我使用 jQuery DataTable 创建 dataGrid。但是,我发现当 mData 的值为 null 时更新单元格时出现问题,如下代码所示:

var oTable = $("table#table_lookup").dataTable({
"bLengthChange": false,
"bFilter": false,
"sPaginationType": "full_numbers",
"aaData": data,
"aoColumnDefs": [{
"sTitle": "No.",
"mData": null,
"aTargets": [0],
"bSortable": false,
"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
$(nTd).text((iRow + 1));
}],
"bAutoWidth": false,
"aaSorting": [[ 1, 'asc' ]]
});

谁能帮我解决这个问题?

最佳答案

mData为空,需要指定sDefaultContent可以设置一个空字符串""的选项,比如:

var oTable = $("table#table_lookup").dataTable({
"bLengthChange": false,
"bFilter": false,
"sPaginationType": "full_numbers",
"aaData": data,
"aoColumnDefs": [{
"sTitle": "No.",
"mData": null,
"sDefaultContent": "", //add this
"aTargets": [0],
"bSortable": false,
"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
$(nTd).text((iRow + 1));
}],
"bAutoWidth": false,
"aaSorting": [[ 1, 'asc' ]]
});

关于javascript - jQuery DataTable : Callback function(fnUpdate, fnCreatedCell 等)如果 mData 为空则不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20208128/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com