fnGetData() not behaving as expected

fnGetData() not behaving as expected

JamesJames Posts: 5Questions: 0Answers: 0
edited July 2009 in General
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

Replies

  • JamesJames Posts: 5Questions: 0Answers: 0
    Actually I should add that I think I'm using 1.5b9 (even though the text in the header still says beta 8) - the header in the min file and code/distribution may be slightly out of sync.
  • JamesJames Posts: 5Questions: 0Answers: 0
    By stepping through the code I think I answered this myself...

    bUseRendered:false

    ...ensures the underlying data is returned from the fnGetData() function.

    Might be worth mentioning that in the docs. But I'm happy :-)
  • allanallan Posts: 62,211Questions: 1Answers: 10,205 Site admin
    Hi James,

    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
This discussion has been closed.