How to move row detail column to last of record?
How to move row detail column to last of record?
Hi,
I'm new to the field of javascript, and I want move the row detail column to last of record.
http://www.datatables.net/examples/api/row_details.html
I think the column with details_open.png was specified by following code to be insert to first of record, but I don't know how to modify it to be insert to last of record.
[code]
$('#example thead tr').each( function () {
this.insertBefore( nCloneTh, this.childNodes[0] );
} );
$('#example tbody tr').each( function () {
this.insertBefore( nCloneTd.cloneNode( true ), this.childNodes[0] );
} );
[/code]
Please give me an advice.
I'm new to the field of javascript, and I want move the row detail column to last of record.
http://www.datatables.net/examples/api/row_details.html
I think the column with details_open.png was specified by following code to be insert to first of record, but I don't know how to modify it to be insert to last of record.
[code]
$('#example thead tr').each( function () {
this.insertBefore( nCloneTh, this.childNodes[0] );
} );
$('#example tbody tr').each( function () {
this.insertBefore( nCloneTd.cloneNode( true ), this.childNodes[0] );
} );
[/code]
Please give me an advice.
This discussion has been closed.
Replies
Provide a column at the end of the in your markup for your details_open.png to be shown and change your this.childNodes[0] to the relevane column number ( numbering starts from 0 hence childNodes[0] denotes the first column].
If you have a table of 6 columns (0 to 5) and you want to have the details_open.png in the last, your this.childNodes[0] would become
[code]
this.insertAfter( nCloneTh, this.childNodes[5] );
[/code]
Hope this helps.
- Girish
Thank you for your help!!!
"this.insertAfter" did not work, but somohow "this.insertBefore" with altered childNode DID work!
Surprisingly, the number of childNodes of Td and Th was different for some reason.
[code]
$('#example thead tr').each( function () {
this.insertBefore( nCloneTh, this.childNodes[26] );
} );
$('#example tbody tr').each( function () {
this.insertBefore( nCloneTd.cloneNode( true ), this.childNodes[17] );
} );
[/code]
I have the table with 7 column and hidden 8 column, and if I change it to this.insertBefore( nCloneTh, this.childNodes[17], a header of detail will appear in 5th column.
Anyway, I think I found that a bit of JAVA script is.
Thank you!
- Mizuneko