Deferred rendering with DOM as dataSource
Deferred rendering with DOM as dataSource
Hello Everyone,
Well directly to the point, I am developing a fileListing web application (something like a webFileBrowser).
In the server side I am creating an .xml document with all the data that I need that later is "parsed" by an .xslt , so in the return of by ajax call I already have a "DOM" html table in a variable (and some other html elements, but this is irrelevant because at the end I have the table in a variable).
The next step is that I am replacing the existing table with the new one and at the end I am calling the dataTable creation
[code] $("#mySelector").dataTable({ options.... });[/code]
The problem comes here.. In case of a big amount of data this procedure could take a really big amount of time (e.x. for 10rows ~600ms for 1.500rows ~8.000ms, 15.000 ~95.000ms and some tests that I did with >35.000rows took more than half an hour in the cases that the browsers did not crash etc) The time periods mentioned above are only from the dataTable(); function.
The limitations:
1) I can not change the form of the "incomming" data (I could just get xml data as responce, but this would cause a lot of problems while at the moment I am saving a lot of data as attributes to the tr-td-table-div etcetera html elements in the xslt file)
2)I currently (maybe it will be possible in the future) can not parts from the data (for example the first 1000) mainly for performance reasons (everytime that I do a request there are a lot of checks that have to be made, so transactions for small amount of data are time-costly)
The theoretical solution: partially rendering from the responce to the DataTable (with scrolling)
PS: The user is informed that he has to wait, and this may be for a big amount of time, and there is no problem if this time is even few minutes in the worse case.. but ofcourse not half an hour
So, is this possible? That exists for ajax-server side requests as I have seen, is there any chance for modification that it will work with dom elements also?
Well directly to the point, I am developing a fileListing web application (something like a webFileBrowser).
In the server side I am creating an .xml document with all the data that I need that later is "parsed" by an .xslt , so in the return of by ajax call I already have a "DOM" html table in a variable (and some other html elements, but this is irrelevant because at the end I have the table in a variable).
The next step is that I am replacing the existing table with the new one and at the end I am calling the dataTable creation
[code] $("#mySelector").dataTable({ options.... });[/code]
The problem comes here.. In case of a big amount of data this procedure could take a really big amount of time (e.x. for 10rows ~600ms for 1.500rows ~8.000ms, 15.000 ~95.000ms and some tests that I did with >35.000rows took more than half an hour in the cases that the browsers did not crash etc) The time periods mentioned above are only from the dataTable(); function.
The limitations:
1) I can not change the form of the "incomming" data (I could just get xml data as responce, but this would cause a lot of problems while at the moment I am saving a lot of data as attributes to the tr-td-table-div etcetera html elements in the xslt file)
2)I currently (maybe it will be possible in the future) can not parts from the data (for example the first 1000) mainly for performance reasons (everytime that I do a request there are a lot of checks that have to be made, so transactions for small amount of data are time-costly)
The theoretical solution: partially rendering from the responce to the DataTable (with scrolling)
PS: The user is informed that he has to wait, and this may be for a big amount of time, and there is no problem if this time is even few minutes in the worse case.. but ofcourse not half an hour
So, is this possible? That exists for ajax-server side requests as I have seen, is there any chance for modification that it will work with dom elements also?
This discussion has been closed.
Replies
One possible solution is to XSLT your data in a Javascript array which you can feed to aaData for the DataTables data source. That way you could use deferred rendering, since the nodes are not needed up front.
What browser are you using btw? 35'000 rows should not cause any browser to crash (with the possible exception of IE if you have the DataTable in a hidden element, or its IE8-).
Allan
IE8 crashes at 40.000 (and chrome that I randomly tested without dataTables but only with enchanted tables with some jquery plugins) and works till ~35.000. Both IE and FF need a really big - non responding - period of time till they render with the classic "script not responding" popups.
My basic problem is that most of the information is stored in attributes at the TR elements (each TR contains more than 10 attr, that may be from "strings" with ~100chars till boolean values)
On recent timed tests that I did with ~15.000 elements the time needed from the server response till they where fully displayed on DataTables was splited about 40% for first DOM creation and 60% for dataTables();
I will give it a try to store the information in JS array and then pass it to dataTable.
Thanks for the suggestion and the existance of dataTables.
Using a Javascript array and deferred rendering should give you a nice speed boost, so that certainly sounds like a good direction to go to me.
Allan
Could you please provide me, if possible, an example of code that could do that? (the format of the data - I guess json - and how is this call done in dataTables.. I found some solutions till now but they seem deprecated..
You can add custom attributes using fnCreatedRow .
Allan