How do i append a row to nRow, using fnRowCallback?
How do i append a row to nRow, using fnRowCallback?
EvanCarroll
Posts: 7Questions: 1Answers: 0
I'm trying to write an example of a table, that just appends a blank row with stuff. The currently example of this is broken. I'm looking to figure out what I have to do here, to get $tr to append to nRow. This is a very simple question because I've removed the more complex and useful portions.
[code]
$(document).ready( function () {
oTable = $("table").dataTable({
bJQueryUI: true
, bPaginate: false
, bAutoWidth: false
, fnRowCallback: function( nRow, aData, iDisplayIndex ) {
var $tr = $('').append(
$('', { colspan: $(nRow).children('td').length, text:'HALLO WIN' } )
)
// Something here to append $tr to nRow
return nRow
}
})
} )
[/code]
[code]
$(document).ready( function () {
oTable = $("table").dataTable({
bJQueryUI: true
, bPaginate: false
, bAutoWidth: false
, fnRowCallback: function( nRow, aData, iDisplayIndex ) {
var $tr = $('').append(
$('', { colspan: $(nRow).children('td').length, text:'HALLO WIN' } )
)
// Something here to append $tr to nRow
return nRow
}
})
} )
[/code]
This discussion has been closed.
Replies
So the question is how to achieve the same effect... You can use fnOpen which will do something similar, or you could simply parse over the table in the DOM after DataTables has drawn and insert the rows there.
Allan
https://developer.mozilla.org/en/insertbefore
That append was just verbial. I was hoping you would fill in the blank with whatever worked. This question is a follow up on this: http://datatables.net/forums/comments.php?DiscussionID=57&page=1#Item_14 I'm just trying to find a static way to do this that works with multiple pages.
There is no way to use fnRowCallback to do exactly what you are looking for here - only one node can be added to the DOM. As I mentioned, using fnDrawCallback could be used to do as you need - or possibly even fnRowCallback to store references to all of the nodes you want to add something after, and then fnDrawCallback to do the insert.
Allan