when adding responsive:true with groupColumn it is showing an error
when adding responsive:true with groupColumn it is showing an error
function initializeTable() {
var groupColumn = 3;
var provisionings_table = $('.provisioning-table').DataTable({
columnDefs: [{ visible: false, targets: groupColumn }],
order: [[groupColumn, 'desc']],
displayLength: 25,
drawCallback: function (settings) {
var api = this.api();
var rows = api.rows({ page: 'current' }).nodes();
var last = null;
api.column(groupColumn, { page: 'current' })
.data()
.each(function (group, i) {
if (last !== group) {
$(rows)
.eq(i)
.before(
'<tr class="group"><td colspan="6">' +
group +
'</td></tr>'
);
last = group;
}
});
//Footer responsiveness
var colspan = api.columns(':visible').count();
if (colspan > 2) {
$('#footer-sum-text').attr('colspan', (colspan - 1));
$('#footer-sum-text').show();
$('#footer-sum-qty').show();
$('#footer-sum-text span').addClass("d-none");
} else {
$('#footer-sum-text').attr('colspan', (colspan));
$('#footer-sum-text').show();
$('#footer-sum-text span').removeClass("d-none");
}
}
});
// Order by the grouping
$('.provisioning-table tbody').on('click', 'tr.group', function () {
var currentOrder = provisionings_table.order()[0];
if (currentOrder[0] === groupColumn && currentOrder[1] === 'asc') {
provisionings_table.order([groupColumn, 'desc']).draw();
}
else {
provisionings_table.order([groupColumn, 'asc']).draw();
}
});
}
error: Cannot read properties of null (reading 'nodeName')
when adding responsive:true, it is showing an error and break the layout for desktop too
Answers
Looks like your code is based on this example. I built a test case with that example and added responsive. There aren't any errors displayed:
https://live.datatables.net/nusajupu/1/edit
Please update my test case or provide a link to your page or test case replicating the issue so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
You may want to consider using the RowGroup extension which enhances that example.
Kevin
Thanks Kevin, you're right, my code is based on the given example. when I add responsive: true with rowGroup: {dataSrc: 3 }. This break table for desktop too and showing below error in console and when adding rowGroup it is showing column twice
Hi,
Kevin's example has Responsive enabled. Can you update that example or link to your own showing the issue so I can debug it?
Allan
@allan it's dashboard panel on laravel, I can't share link as public. how can I make my credentials private?
here is my html ```
```
and here is my JS code
I'm executing this function in below code
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
I copied your
initializeTable()
code into this test case:https://live.datatables.net/wesodadu/1/edit
I only modified the
groupColumn
value. The code does not result in any errors.The test case is using the current version of Datatables and Responsive. Maybe you need to upgrade. Use the Download Builder to get the current versions.
Click on Allan's name in the thread and you can send him a PM with the login information.
Kevin
@allan I updated the library but still getting a same error.
@allan I sent you an message with link and credentials.
Many thanks! It looks like the service might be down at the moment (laptop sleeping? ). I'll try again later on.
Allan
Thanks @allan I got the issue fixed with css.