Hi,
I use the
fnRender feature to display the row number in a column.
It works well when I dynamically add a row (via fnAddData). However when I delete a row (via fnDeleteRow),
fnRender is not invoked.
Is it a bug ? Another approach ?
Any help would be appreciated
jquery.dataTables.js: 1.8.2
Replies
Having said that, fnRender is deprecated and shouldn't be used. it will be removed in v1.10. Use mRender instead.
Allan
I'm not sure what's the best place to implement it; fnDrawCallback I guess.
Thank you
You'd need to call fnUpdate on all of the other rows, since you are updating those rows.
Allan
I upgraded to jquery.DataTables 1.9.4.
I migrated my fnRender stuff to mData and mRender.
I moved the 'row number' logic to fnRowCallback.
Now the problem I'm encountering is that my datasource is an array of integers and mData expects an object, not a primitive.
So to circumvent this, I have to wrap my primitives like this:
function wrapElementsOf(array) {
var wrapped = [];
for (var i = 0; i < array.length; i++) {
wrapped.push({"value": array[i]});
}
return wrapped;
}
Thanks
mData should work just fine with primitives. Can you link me to an example which doesn't work?
Allan
Two issues here:
> mData: ""
Is meaningless. If you want `data` in the mRender method to take the value of the data source object, you should use `null` .
The other issue is that DataTables 1.9- doesn't support this kind of data - it requires objects or arrays as the data source object.
However, DataTables 1.10 which is currently in development has lifted that restriction, as you can see here: http://jsfiddle.net/aPQPQ/8/ (I've cheated and just used the file from Github, you shouldn't do that in anything other than a simple test like this!).
Although 1.10 is in development, it has that change in it can you can use it now.
Allan