slow performance "fnRowCallback"

slow performance "fnRowCallback"

haraulharaul Posts: 5Questions: 1Answers: 0
edited November 2014 in Free community support

Background:

we are using datatables v1.9.4 (server side processing) with other add-ons for showing/hiding columns, Fixed headers, sorting, filtering, pagination, changing number of rows on fly, export funtionality etc (basically we have written our own plugin to combine these all features).

Problem:

We have approx. 30 columns on each table and use ajax calls for table data (JSON). Some of these columns has links, styles and last column is actions which shows 5 or 6 icons for different operations. This all extra stuff is generated through "fnRowCallback"; Because of this row callback, table rendering has become quite slow (i.e. during initialisation time, sorting, filtering, pagination etc requires rendering of table).

Question 1: Please may I know if this is correct approach to add links/styles to the table data (i.e. by using fnRowCallBack) or is there any other better way of doing this?

We use Converter classes (Java) which convert entities to json data. One way could be to add html code here on top of data for styles/links but it will be messy (i.e. mixing data and html together) and not sure if datatables would be able to handle it properly for rendering, filtering etc. I tries it and it was was showing added html code as raw data e.g added div was showing it as tag.

Another solution could be that for some columns (which requires heavy dom manipulation), we an defer the style/links until user clicks on that column but not sure yet!

Question 2: Do you think upgrading Datatables from version 1.9.4 to 1.10.x would help? I can see there are options like "rowCallback", "columns.render", "createdCell", "createdRow" etc; Could this be better approach?

Any help is greatly appreciated; thanks in advance!

Kind Regards,

Harry

Answers

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    With server-side processing, fnRowCallback is probably okay. I doubt you'll see much difference if you update to 1.10 in terms of performance for this, if you are only displaying 10 rows at a time.

    I'd suggest profiling the code in Chrome or Firefox and see what is taking so long and see if it can be optimised. Without a link to the page I can't really offer much help.

    Allan

  • haraulharaul Posts: 5Questions: 1Answers: 0

    Hi Allan!

    Sorry got stuck to something and took some time to come back.

    I've profiled my code on FF and can see that network requests takes approx 750ms but to DOM generation takes ages (7 to 8 secs) (for 250 records).

    I'll see if I can find anything from profiling as well and let you know further.

    Please can I send you the link with userid/pwd privately just to have your opinion?

    Thanks in advance!
    Harry

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Sure - click on my name above and then "send message".

    Allan

This discussion has been closed.