xmlhttp.responseText 后数据表无法正确呈现
DataTable not Rendering corrrectly after xmlhttp.responseText
DataTable
正在显示,但仅在我更改每页的项目数之后。同样,分页仅在我搜索某个项目时才起作用。
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var col = [{
"mData": "row1"
}, {
"mData": "row2"
}, {
"bSortable": false,
"mData": null,
"sTitle": "Actions",
"bSearchable": false,
"mRender": function(data, type, full) {
return '<a href="' + full.link + '"><img alt="Download" src="https://upload.wikimedia.org/wikipedia/commons/e/e3/Ppbc_icon_download.png" title="Download"/></a>';
}
}];
var ss = JSON.parse(xmlhttp.responseText);
$('#myTable').dataTable({
"aaData": ss,
"aoColumns": col,
"bDestroy": true
});
}
};
而不是 aoColumns
,使用 columns
。
var col = [{
"mData": "row1",
"sTitle": "row1"
}, // <-- which values to use inside object
{
"mData": "row2",
"sTitle": "row2"
}, {
"bSortable": false,
"mData": null,
"sTitle": "Download",
"bSearchable": false,
"mRender": function(data, type, full) {
return '<a href="' + full.Link + '"><img alt="Download" src="https://upload.wikimedia.org/wikipedia/commons/e/e3/Ppbc_icon_download.png" title="Download"/></a>';
}
}];
JSON.parse(xmlhttp.responseText);
var ss = $('#myTable').dataTable({
"aaData": ss,
"columns": col,
"bDestroy": true
});
}
};
DataTable
正在显示,但仅在我更改每页的项目数之后。同样,分页仅在我搜索某个项目时才起作用。
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var col = [{
"mData": "row1"
}, {
"mData": "row2"
}, {
"bSortable": false,
"mData": null,
"sTitle": "Actions",
"bSearchable": false,
"mRender": function(data, type, full) {
return '<a href="' + full.link + '"><img alt="Download" src="https://upload.wikimedia.org/wikipedia/commons/e/e3/Ppbc_icon_download.png" title="Download"/></a>';
}
}];
var ss = JSON.parse(xmlhttp.responseText);
$('#myTable').dataTable({
"aaData": ss,
"aoColumns": col,
"bDestroy": true
});
}
};
而不是 aoColumns
,使用 columns
。
var col = [{
"mData": "row1",
"sTitle": "row1"
}, // <-- which values to use inside object
{
"mData": "row2",
"sTitle": "row2"
}, {
"bSortable": false,
"mData": null,
"sTitle": "Download",
"bSearchable": false,
"mRender": function(data, type, full) {
return '<a href="' + full.Link + '"><img alt="Download" src="https://upload.wikimedia.org/wikipedia/commons/e/e3/Ppbc_icon_download.png" title="Download"/></a>';
}
}];
JSON.parse(xmlhttp.responseText);
var ss = $('#myTable').dataTable({
"aaData": ss,
"columns": col,
"bDestroy": true
});
}
};