Please un-deprecate fnRender
Please un-deprecate fnRender
jctsay
Posts: 1Questions: 0Answers: 0
HI Allan,
First of all, great job on datatables! It works very well and looks great. I've been using it since 2009 (?) for a variety of projects.
After upgrading from 1.8.3 to 1.9.4 I discovered that fnRender is deprecated in column defs. This is a bummer for me since I was doing things like this:
$('table').dataTables({
aoColumns : [
{
mDataProp: 'summaryStatistics.rating',
bSortable : true,
fnRender : function (obj) {
var ss = obj.aData;
return ss.rating + ' | ' + ss.numUsers + ' users'
}
}
...
]
});
where the data looks like this
[
{ "summaryStatistics" : { "rating" : 3.0, "numUsers" : 400} },
{ "summaryStatistics" : { "rating" : 1.0, "numUsers" : 23} }
]
I tried to change fnRender to mRender, but discovered the function is called differently. mRender is called with the mData value, while in this case is the rating. But fnRender was called with the entire row's data, so I can look at multiple fields of the row. I could change mDataProp to just 'summaryStatistics', but then I would lose the sorting ability on the rating. If there is no workaround for this, I would suggest un-deprecating fnRender.
Thanks!
Jeff
First of all, great job on datatables! It works very well and looks great. I've been using it since 2009 (?) for a variety of projects.
After upgrading from 1.8.3 to 1.9.4 I discovered that fnRender is deprecated in column defs. This is a bummer for me since I was doing things like this:
$('table').dataTables({
aoColumns : [
{
mDataProp: 'summaryStatistics.rating',
bSortable : true,
fnRender : function (obj) {
var ss = obj.aData;
return ss.rating + ' | ' + ss.numUsers + ' users'
}
}
...
]
});
where the data looks like this
[
{ "summaryStatistics" : { "rating" : 3.0, "numUsers" : 400} },
{ "summaryStatistics" : { "rating" : 1.0, "numUsers" : 23} }
]
I tried to change fnRender to mRender, but discovered the function is called differently. mRender is called with the mData value, while in this case is the rating. But fnRender was called with the entire row's data, so I can look at multiple fields of the row. I could change mDataProp to just 'summaryStatistics', but then I would lose the sorting ability on the rating. If there is no workaround for this, I would suggest un-deprecating fnRender.
Thanks!
Jeff
This discussion has been closed.
Replies
So is mRender - the third parameter is the data source for the row :-). No need for a workaround, this feature is already built in.
fnRender has already been removed in git and good riddance to it! It was seriously holding back other advancements in DataTables when working with data source objects (requiring data to be cloned, thus breaking links so Backbone etc integration was out and is a large performance drag), it was confusing with bUseRendered and limiting.
mRender is a much better solution all around - promise!
Allan
Big mistake removing fnRender(). mData() and mRender() have nowhere near the functionality. Specifically, the following are not passed into the new mData() and mRender() functions:
iDataRow
iDataColumn
oSettings
mDataProp
This makes it pretty much impossible to introspect the dataTable, or anything about which row index or column index you happen to be rendering, or the corresponding aoColumns, from within mData() or mRender(). That's some VERY important functionality, just cavalierly tossed out the window by the dataTables team.
Way to go! DataTables is now on the fast track to irrelevance. Too bad its development team don't bother to listen to real users. Looks like they could use a lesson in design-by-contract. You must ALWAYS preserve old APIs, even if that means emulating them. APIs are a contract.