pagination, ordering, search such as other features are not working....
pagination, ordering, search such as other features are not working....
JINUU
Posts: 1Questions: 1Answers: 0
i can't find out wrong point
datas are parsed well but pagination, ordering, search such as other features are not working....
does it matter caused by updating each datas on cell? -> plugin doesn't catch new datas?
please let me know...ㅜㅜ
$('#example2').DataTable({
"paging": true,
"lengthChange": false,
"searching": false,
"ordering": true,
"pageLength": 15,
"info": true,
"autoWidth": false,
"responsive": false,
drawCallback: function(){
$('#example2_previous a').text('◀');
$('#example2_next a').text('▶');
}
});
$.ajax({
url: '/api',
type: 'POST',
data: JSON.stringify({"command":"getUnitList"}),
dataType: 'json',
success: function(data) {
if (data.error == 0) {
console.log(data.reply);
console.log(data.reply.data.length);
console.log(data.reply.data[0].apt_number);
console.log(data.reply.data[1].apt_number);
populateTable(data.reply); // 성공 콜백에서 테이블을 채우는 함수 호출
}
else {
console.log(data.errorString);
}
},
error: function (xhr, msg, err) {
console.log('code:' + xhr.status + '\n' + 'message:' + xhr.responseText + '\n' + 'error:' + err);
if(xhr.status == 401)
location.href = '/';
},
complete: function (jqXHR) {
console.log('api getInfo complete');
}
});
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
I suspect the issue is within
populateTable()
.If you are adding the rows directly into the table's HTML, then DataTables won't know about those rows so will keep reporting that there are 0 rows in the table. You need to call
rows.add()
(orrow.add()
multiple times) to add those rows through the API.The alternative is load the data directly via Ajax as demonstrated in the examples in this section,
Colin