Column render current page only

Column render current page only

RobertSemenoffRobertSemenoff Posts: 4Questions: 2Answers: 0

Column render seems to get called for every row.
For my 10,000 row table, it seems to be getting bogged down and I have to kill the tab
and reload the page in a new tab ...
Is there way to have it render only the current page ?
If not, is there pre-draw event that I can handle and then render myself
using api().rows({page:'current'}) ?
Thanks for any advice,
Rob

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974
    Answer ✓

    I think you want to try the deferRender option so only the rows being shown will be rendered.

    Kevin

  • RobertSemenoffRobertSemenoff Posts: 4Questions: 2Answers: 0

    Well that seemed to improve things, but actually not.
    I have a console.log("zxcv") in the column render handler.
    I was seeing fewer calls to the renderer, but that was just because
    I didn't open the developer tools console (Chrome browser) until after
    the render completed (which it does correctly so far) .
    But if I change the filter or ordering so that a different row range comes into view,
    there's no additional calls to the renderer (although the cells have actually been rendered). Also, if I have the developer console open as the page loads, it does still show over 10,000 calls to the renderer.

    Incidentally, I'm not using ajax (as an option to the Datatable) as in the example in the deferRender doc. Might that be the problem ?

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974

    The deferRender docs state this:

    By default, when DataTables loads data from an Ajax or Javascript data source (ajax and data respectively) it will create all HTML elements needed up-front.

    So yes, deferRender works with Javascript or Ajax loaded data. See this FAQ. Maybe orderClasses will help.

    Kevin

  • RobertSemenoffRobertSemenoff Posts: 4Questions: 2Answers: 0

    I will prepare a test case.
    In the meantime, I noticed, by setting a breakpoint in the renderer, I can
    watch as each cell gets rendered. At this point, the table looks very raw HTML,None of the datatable features seem to be applied, including pagination, so it is definitely going through the whole table. So should the render function be attached to the datatable object not in the constructor but sometime later like in the "initComplete" ??

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    I'm not too clear on the question, but initComplete is called when the initialisation is complete and the table is ready to be used. The options Kevin suggested, are also initialisation options.

    Colin

Sign In or Register to comment.