Add Class to new row using scroller plug-in
Add Class to new row using scroller plug-in
I tried using what Allan suggested on this post, http://www.datatables.net/forums/discussion/181/fnadddata-and-add-class/p1
[code]
var newRowAdding = groupTable.fnAddData([
userData[0],
userData[1],
userData[2],
userData[3]
]);
var newRow = groupTable.fnSettings().aoData[ newRowAdding[0] ].nTr;
if ($(this).hasClass('changed')) {
newRow.setAttribute('class', '');
} else {
newRow.setAttribute('class', 'changed');
}
[/code]
This works, but only so long as the row being added is currently in the scroller view (which make sense since it is merely looking for the latest row added to the DOM). Is there something else I can do to add a class to a row?
[code]
var newRowAdding = groupTable.fnAddData([
userData[0],
userData[1],
userData[2],
userData[3]
]);
var newRow = groupTable.fnSettings().aoData[ newRowAdding[0] ].nTr;
if ($(this).hasClass('changed')) {
newRow.setAttribute('class', '');
} else {
newRow.setAttribute('class', 'changed');
}
[/code]
This works, but only so long as the row being added is currently in the scroller view (which make sense since it is merely looking for the latest row added to the DOM). Is there something else I can do to add a class to a row?
This discussion has been closed.
Replies
Is there a way to snag the index of the row that was just created?
Something like...
[code]
var newRowAdding = groupTable.fnAddData([
userData[0],
userData[1],
userData[2],
userData[3]
]);
var oSettings = groupTable.fnSettings();
oSettings.oScroller.fnScrollToRow(newRowAdding[0]);
var newRow = groupTable.fnSettings().aoData[ newRowAdding[0] ].nTr;
if ($(this).hasClass('changed')) {
newRow.setAttribute('class', '');
} else {
newRow.setAttribute('class', 'changed');
}
[/code]
note, this doesn't work. it just scrolls me to the bottom of the table from the top of the table, even if I was originally in the middle of the table.
Allan