Write all rows to .txt but dont use all for init

Write all rows to .txt but dont use all for init

SebSeb Posts: 5Questions: 0Answers: 0
edited November 2011 in General
hey all,
i write my db results to a txt file using json_encode and output it via sAjaxSource, which works fine. However on our project the data loaded is to heavy, although only 900 rows. Properbly to other jquery stuff, but we cant remove any of them

Well to the questions. When i let sajaxsource load the data
[code] "sAjaxSource": "dataset.txt",
[/code]
it loads all of it at once from the txt file. Does it support a function to have it work like this way of some sort?

- let sajaxsource only read the first 10 of these total 900 records from the txt file to speed up the initialization in our case. Then when searching or using pagination, it reads the next 10 etc.

Thank you

Replies

  • GregPGregP Posts: 500Questions: 10Answers: 0
    When reading in a flat data file, the full set of data is always stored to a data object, and then only portions of it are rendered according to your initialization. That's as optimized as it will get; if you sort or filter, it will do so on the full data object each time. And for good reason: you don't want to sort on only 10 records!

    There is indeed a way to accomplish your END goal: that is to use server-side processing (http://datatables.net/usage/server-side); however, the two things are exclusive. To do it the "right" way, you have to use server-side code to generate and return your data set. You cannot just use a flat data file.

    This is a limitation of how AJAX works, not DataTables itself.
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    One thing in addition to what Greg says - have you tried enabled deferred rendering ( bDeferRender )? THat should give a significant speed boost. Also you can use the Webkit dev tools to see how long your Ajax file is taking to look, to see if that would be the problem.

    Allan
This discussion has been closed.