fnGetData() not behaving as expected
fnGetData() not behaving as expected
Hi Allan, me again.
From the docs, I imagined that fnGetData() would return the underlying data for a table, not the rendered results.
However, the following code, with 1.5.0 beta 8, spits out the rendered HTML (span, style et al), rather than just the word 'red', which is what I had expected.
[code]
UnrenderedRendered
Ared
Bblue
$(document).ready(function() {
dt = $('#dt').dataTable({
"aoColumns":[
{},
{fnRender:function(obj){
colour = obj.aData[obj.iDataColumn];
return "" + colour + "";
}}
]
});
alert(dt.fnGetData(0));
});
[/code]
Known issue? Misunderstanding on my part? A way to get around it? (without having to reverse the rendering tranformation!)
Many thanks
James
From the docs, I imagined that fnGetData() would return the underlying data for a table, not the rendered results.
However, the following code, with 1.5.0 beta 8, spits out the rendered HTML (span, style et al), rather than just the word 'red', which is what I had expected.
[code]
UnrenderedRendered
Ared
Bblue
$(document).ready(function() {
dt = $('#dt').dataTable({
"aoColumns":[
{},
{fnRender:function(obj){
colour = obj.aData[obj.iDataColumn];
return "" + colour + "";
}}
]
});
alert(dt.fnGetData(0));
});
[/code]
Known issue? Misunderstanding on my part? A way to get around it? (without having to reverse the rendering tranformation!)
Many thanks
James
This discussion has been closed.
Replies
bUseRendered:false
...ensures the underlying data is returned from the fnGetData() function.
Might be worth mentioning that in the docs. But I'm happy :-)
Yes indeed you are correct - bUseRendered is the thing you are looking for here. In this way you can select if you want the raw data or the rendered data - something for everyone :-)
The reason it isn't documented yet is that this is in DataTables 1.5 only - and since this is currently in beta the documents refer to the current "stable" release of 1.4 (actually 1.5 beta 9 is probably more stable than 1.4.3 in all honestly - but there are a few things I want to do before removing the beta tag...).
Regards,
Allan