我想填充表中的列標題和它的身體與數據,但它無法使ajax調用如果。如何從ajax調用加載完整的數據表?
<table id="datatable1" cellpadding="0" cellspacing="0" border="0" class="display" width="100%">
<thead>
</thead>
<tbody>
</tbody>
</table>
我離開這兩個頭部和身體空。 但添加一些隨機標題。
<thead>
<tr>
<th>Random column title</th>
</tr>
</thead>
修復它。雖然我的意思是從JSON字符串同時添加列名和數據,並將它添加到表中,但它不會讓我:
我也能夠從數據庫加載的東西沒有問題,如果沒有問題事先建立正確的aoColumns
和mData
。
var oTable; //datatable reference
var start = 0; //first row's id to load
var qty = 100; //number of rows to load
var DESC = "false"; //load last row first and go down?
var type = "something";
var ajaxURL = GLOBAL_ROUTE + "api/application/datatable/fillTable/" + type + "/" + start + "/" + qty + "/" + DESC;
oTable = $('#datatable1').dataTable({
"sPaginationType" : "full_numbers",
"sDom" : '<"top"<"length"l><"search"f><"position">>rt<"bottom"<"info"i><"pages"p>>',
"bProcessing" : false,
"bServerSide" : false,
"sAjaxSource" : ajaxURL,
"bDeferRender" : true,
/*"aoColumns" : [ {
"mData" : "a"
}, {
"mData" : "b"
}, {
"mData" : "c"
}, {
"mData" : "d"
} ]*/
});
alert("asasd"); //this alert is not even reached if no header/body/aoColumns are set.
迂迴方式,而不調用Ajax事先與列名?