can hidden row toggle column be something OTHER than column 0?
can hidden row toggle column be something OTHER than column 0?
The example here: http://www.datatables.net/release-datatables/examples/api/row_details.html, gives a great example of how to add a toggle column that, when the toggle image is clicked on a particular row, a hidden row below that is then shown with additional data. GREAT FEATURE. The example shows the column created as becoming column 0.
I have 8 columns in my table and I want the toggle image to be in column 5. Was thinking it would be as simple as revising the "childNodes[0] in the code below to childNodes[4], but that seems to cause problems. Is it able to be done in the current version of DataTables? If so, can an example be provided like that on the page referenced above?
..................
$('#classlist thead tr').each( function () {
this.insertBefore( nCloneTh, this.childNodes[0] );
} );
$('#classlist tbody tr').each( function () {
this.insertBefore( nCloneTd.cloneNode( true ), this.childNodes[0] );
} );
..................
Thanks.
I have 8 columns in my table and I want the toggle image to be in column 5. Was thinking it would be as simple as revising the "childNodes[0] in the code below to childNodes[4], but that seems to cause problems. Is it able to be done in the current version of DataTables? If so, can an example be provided like that on the page referenced above?
..................
$('#classlist thead tr').each( function () {
this.insertBefore( nCloneTh, this.childNodes[0] );
} );
$('#classlist tbody tr').each( function () {
this.insertBefore( nCloneTd.cloneNode( true ), this.childNodes[0] );
} );
..................
Thanks.
This discussion has been closed.
Replies
If you are using Ajax loaded data, it is actually easier to use sDefaultContent rather than manipulating the DOM that way - but if you've got a DOM sourced table, that might be the best way of doing it.
Allan
And a VERY minor FYI, the example on this page: http://www.datatables.net/extras/fixedheader/options for "offsetTop" has "table" where it should be "oTable". Threw me off for a second. By the way, is there any conflict where fixedheader will not work when hidden rows are also being used?
> So the question I have now is, why use childNodes in the example as opposed to getElementsByTagName('th')[5]?
Because it is heck of a lot faster to use childNodes if you just want the first and you know the structure. However, that doesn't account for text nodes, which is likely what you are hitting, so yes, using jQuery of getElementsByTag name might be better long term.
Allan