我在服务器端处理中使用 jQuery Datatable,这是我的代码。只要我为其中的操作按钮再添加一列,它就可以正常工作,它只是停止渲染。任何帮助将不胜感激。
$("#table1").dataTable({
"processing": true,
"serverSide": true,
"info": true,
"lengthMenu": [[5, 35, 50, -1], [5, 35, 50, "All"]],
"ajax": {
"url": "/Customer/customers",
"type": "POST"
},
"columns": [
{ "data": "displayName", "orderable": true },
{ "data": "email", "orderable": true },
{ "data": "state", "orderable": true },
{
"data": "licenses", "orderable": true,
"render": function (data, type, row) {
if (type === 'display') {
if (data > 0)
return '<i class="fa fa-check" aria-hidden="true"></i>';
else
return '<i class="fa fa-times" aria-hidden="true"></i>';
}
return data;
}
},
]
});
这是我在列数组中的许可证之后添加的带有操作按钮的另一列。
{
"data": null, "orderable": false, "render": function (data, type, row) { return '<a href="' + data + '">Download</a>'; }
},
谁能告诉我这里出了什么问题?
在 html 页面中,如果您的列数少于您使用 ajax 呈现的列数,则会显示错误。正如您所说,当再添加一列时它会显示错误,我认为问题在于您的 html 页面中的列较少。如果您固定列数,我认为它会起作用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句