force deferRendering to false after datatables has been rendered

force deferRendering to false after datatables has been rendered

XeliXeli Posts: 4Questions: 1Answers: 0
edited October 2013 in DataTables 1.9
I've build an export to csv funtion for datatables, which does some application specific stuff, like break a column up into seperate column. So I can't really use a generic export function.

This exportfunction works great except when I turn on deferRendering. The reason why it breaks is because the _ (and I assume the $ aswell) doesn't pick up rows that haven't been rendered yet. Makes a lot of sense.

However I really want to the selectors to be able to get all the rows.

So my question is: Is there a way to force the rendering of all the rows?

Replies

  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    > So my question is: Is there a way to force the rendering of all the rows?

    If deferred rendering is enabled, then the only way is by drawing every row. However, if you know that you are going to need the nodes, why enable deferred rendering?

    Allan
  • XeliXeli Posts: 4Questions: 1Answers: 0
    edited October 2013
    The reason why I need to disable deferred rendering is because I need all the nodes when exporting to a csv. But exporting isnt always being done, most of the time someone isn't going to export and in that case the deferred rendering is nice to have.

    Is there a way to 'draw' every row without the user seeing it? Doing it manually I could just click on every page, but I would like a way without the user noticing it.
  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    Currently no. It probably is possible to write a plug-in which would do it, but the easier way might be to do a quick draw with display length -1 and then reset the display length back to what it was.

    Allan
  • XeliXeli Posts: 4Questions: 1Answers: 0
    I used this solution works fine for what I need:

    var settings = table.fnSettings();
    var oldDisplayLength = settings._iDisplayLength;
    settings._iDisplayLength = -1;
    table.fnDraw();
    settings._iDisplayLength = oldDisplayLength;
    table.fnDraw();

    Thanks for the help
This discussion has been closed.