datatables group and change data
datatables group and change data
kaspro
Posts: 4Questions: 1Answers: 0
- Data from static JSON
- Add row in ready
var t = $('#example').DataTable();
t.row.add([
...
]).draw(false);
- Group
$('#example').DataTable({
paging: false,
searching: false,
//ordering: false,
info: false,
columnDefs: [
{
"targets": [ 0 ],
//"visible": false,
"orderable": true
},
{
"targets": [1, 2, 3, 4, 5],
"orderable": false
}],
order: [[0, 'asc']],
//data: dataSet,
rowGroup: {
startRender: null,
endRender: function (rows, group) {
return $('<tr/>')
.append('<td colspan="3">Place ' + group + '</td>')
.append('<td><span class="badge" style="font-size: 21px; display: inline-block;" >0 ед.</span></td>')
.append('<td colspan="3"><td/>');
},
dataSrc: 0
}
- Add new t.row.add([
...
]).draw(false); - Change data
- var t = $('#example').DataTable();
t.cell(rowId, 0).data(box).draw();
After changing the data to the last round, the groups are not updated, only after changing all starts working normally, what do I do wrong?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The grouping information should be updated upon the
draw()
call. I've put a little example together here.Can you link to a test case showing the issue so we can help debug it please.
Allan
Please, change value in combobox from 1 to 2, after duplicate group!
After change all combobox, work normal. link
I'm afraid I don't really understand the example - its quote complex as a test case! Can you give me step by step instructions for what to do?
Allan
Fixed here: http://live.datatables.net/toyukuwo/9/edit
The problem was that when you read the value from the DOM it is read as a string. Thus
"2"
was being being set as the value for the cell, not2
(as a number). RowGroup uses strict type checking - thus the issue.Was what I used to fix it.
Allan
Thank you!