When I add footer to my table this error occurs I don't know why ?
When I add footer to my table this error occurs I don't know why ?
Im new to the datatables. So please help me throught this.
When I add footer to my table a error message comes up like:
jquery.min.js:2 Uncaught TypeError: Cannot read properties of null (reading 'nodeName')
at jquery.dataTables.min.js:141:157
at ub (jquery.dataTables.min.js:127:403)
at Ac (jquery.dataTables.min.js:140:148)
at C.<anonymous> (jquery.dataTables.min.js:142:20)
at C.iterator (jquery.dataTables.min.js:117:304)
at C.<anonymous> (jquery.dataTables.min.js:141:490)
at C.columns (jquery.dataTables.min.js:120:201)
at C.<anonymous> (jquery.dataTables.min.js:145:481)
at C.column (jquery.dataTables.min.js:120:201)
at C.<anonymous> (dataTables.responsive.min.js:37:492)
The Debug code link is given below: https://debug.datatables.net/utiziw
This question has an accepted answers - jump to answer
Answers
This the code I use
and these are the scripts i load
Datatables requires the number of
tfoot
th
elements match the number in the header. You have 16 header columns but you havecolspan="15"
for the footer. Trycolspan="16"
.Kevin
Or, if you don't want the total in the last column add a -tag th` like this:
Kevin
I tried the suggested code. Now the table displays the data, but I can't see the footer. When I tried inspect, I can see tfoot in the html code, but the footer is not being displayed.
I gave colspan as 15, thinking that the columns start form the index 0.
The footer is being displayed when I give the
<tfoot class="tfoot">
<tr>
<th colspan="10" style="text-align:right">Total:</th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</tfoot>
but I need them in the last. Should I need to turn off my responsiveness to display the footer or is there any other way?
Mostly I working on this table for mobile view so the table need to be responsive. In the responsive view I can able to see the footer.
And I have an other issuse like my cells styles are not appearing in the responsive mode.
Not in HTML. Javascript, yes.
If it isn't displaying for you with the above, please link to a test case showing the issue so I can debug it.
Allan
I built a simple test case using your HTML table. Responsive does hide all of the
th
in acolspan
if one or more of them are to be hidden by Responsive, for example:https://live.datatables.net/piviciri/1/edit
Note that I add the classname
all
to the last two columns to make sure they always display. I assume you want the total column to always display. See this example and this doc for more details.@allan will need to comment regarding the use of
colspan
and Responsive.You can create the footer without
colspan
, ie individualth
, to work with Responsive, like this:https://live.datatables.net/ravibiqe/1/edit
The selectors you are using might not find the elements when displayed in the child rows. See the Details Views docs and the
responsive.details.renderer
docs. In the second test case I added classnamegreen
and, in the CSS tab, created a simple style to apply to the responsiveli
. You might need to do something similar. If you need help with this then please update the test case to show what you currently have so we can offer more complete suggestions.Kevin
I don't think it works yet actually. It will with the next major update to Responsive which should drop in January along with DataTables 2.
For now, use individual cells.
Allan
Thanks a lot for your responses. It worked. Next, I need to study something on styling the child row.