iDeferLoading and fnRender conflict

iDeferLoading and fnRender conflict

abecksabecks Posts: 2Questions: 0Answers: 0
edited May 2012 in General
Using DataTables 1.9 jQuery plugin.

I am currently using fnRender to modify the contents of cells like so:

[code]'fnRender': function(o){
var status;
switch(o.aData['status']){
case true: // open
status = 'Open';
break;
default: // closed
status = 'Closed';
}
return status;
}[/code]

This works great for manipulating the DOM of cells. (I'll explain why fnRowCallback doesnt work for me in a minute)

I'm also using iDeferLoading, so my initial table content is already rendered. However, fnRender is being called when the table initializes and it tries to render with a non-existent o.aData object.


I've tried using fnRowCallback instead:
I placed raw data into the table using HTML, so that fnRowCallback can properly render the cell's DOM elements like I was using fnRender for. However, this causes a severe flash of unstyled content between when the table HTML is loaded and the plugin re-renders it. You literally see all the raw data for a second or two before it changes into the desired content.

What is the recommended method of using deferred loading while modifying the content of cells from an AJAX source? I don't want to put all the HTML formatting into my AJAX output, for obvious reasons. It seems that the most optimal setup would be to disable fnRender for the first table load when iDeferLoading is set.

Replies

  • abecksabecks Posts: 2Questions: 0Answers: 0
    I've fixed my issue by switching to fnCreatedCell from fnRender:

    [code]
    'fnCreatedCell': function(nTd, sData, oData){
    if(oData.id !== undefined){
    var status;
    switch(oData.status){
    case true: // open
    status = 'Open';
    break;
    default: // closed
    status = 'Closed';
    }
    $(nTd).html(status);
    }
    }
    [/code]

    Still feels kind of awkward checking to see if oData has anything in it or not.
This discussion has been closed.