Table render Info info.page and pagination one row one page
Table render Info info.page and pagination one row one page
Dear Colleagues, Allan,
I ask you to suggest in the next question.
In a table with a number of simultaneously displayed lines, I try to display the current page number (which is essentially a line) in the table header.
I want to perform the mapping when rewriting the table.
It is interesting that render for fields works, but it is not possible to get the value of table.info. Please tell me how can I do this?
Here is my code:
var table = $('#questions').DataTable( {
dom: "Brtip",
pagingType: "simple",
pageLength: 1,
paging: true,
ordering: false,
info: false,
ajax: "../../controllers/staff_300.php",
columns: [
// {
// className: 'details-control',
// orderable: false,
// data: null,
// defaultContent: ''
// },
{
"targets": 4,
"render": function ( data, type, row, meta) {
return 'Вопрос номер '+data+' ';},
data: "quest_order"
}, {
data: null,
render: function(data, type, row, meta) {
var info = table.page.info();
return '<progress value="'+info.page+'" max="'+info.pages+'"></progress>';
}
},
],
order: [[0, 'asc']],
select: false,
buttons: [],
rowCallback: function ( row, data, index ) {
$('td:first-child', row).attr('title', 'Click to edit');
editor.edit(row,'','');
},
initComplete: function(settings, json){
//var info = this.api().page.info();
//alert('Total records', info.recordsTotal);
}
} );
Yours faithfully,
Andrey
This question has an accepted answers - jump to answer
Answers
Of course I have studied the following links:
https://datatables.net/reference/option/infoCallback
https://datatables.net/reference/api/page.info()
This code works in rowCallback section, but I need it in render (examp row 23-25)
`
var info =new new $.fn.dataTable.Api('#questions').page.info();
$('td:first-child', row).attr('title', 'Click to edit');
editor.edit(row,'<progress value="'+info.page+'" max="'+info.pages+'"></progress>','');
`
The
columns.render
is not intended to have access to the Datatable API. Especially when the table is initializing it is not available.You could use
rowCallback
for this. See this example:http://live.datatables.net/hurasuge/1/edit
Kevin
Good day,
Kevin?
Thanks for the instant reply. I will try to apply your solution.
With respect,
Andrey