Yep, as you say, that won't work. Many initialisation options can't be changed later, and ordering is one of those. What you could do is set the initial order to nothing, with order, then change it to the order you want later with order(). Not quite the same, but hopefully good enough,
Hi Colin,
The idea is to avoid parsing the data set for ordering to speed up first-time load page. After the page is loaded, I can spare 1sec because the user will be busy checking out data so won't notice background calculations.
DataTables is very fast at that initial ordering - if that's the criteria, it would be worth profiling it (if you haven't already) to see how much different it will make. The workaround I mentioned above should do the trick for you, since with ordering set to [], it will just display the data in the order it was loaded,
It is fast, indeed, but I'm loading a small img (country flag) on each column. This takes a few ms/img as it is downloaded on request when the page is first accessed. After caching is not a big deal anymore first impression always matter a lot.
Perhaps you could load the flags as sprites. That should significantly improve initial performance since it wouldn't need multiple requests to get the files (unless you are using http/2 where it wouldn't make that much difference).
Answers
Hi @sharpBCD ,
Yep, as you say, that won't work. Many initialisation options can't be changed later, and
ordering
is one of those. What you could do is set the initial order to nothing, withorder
, then change it to the order you want later withorder()
. Not quite the same, but hopefully good enough,Cheers,
Colin
Hi Colin,
The idea is to avoid parsing the data set for ordering to speed up first-time load page. After the page is loaded, I can spare 1sec because the user will be busy checking out data so won't notice background calculations.
Hi @sharpBCD ,
DataTables is very fast at that initial ordering - if that's the criteria, it would be worth profiling it (if you haven't already) to see how much different it will make. The workaround I mentioned above should do the trick for you, since with ordering set to
[]
, it will just display the data in the order it was loaded,Cheers,
Colin
It is fast, indeed, but I'm loading a small img (country flag) on each column. This takes a few ms/img as it is downloaded on request when the page is first accessed. After caching is not a big deal anymore first impression always matter a lot.
Perhaps you could load the flags as sprites. That should significantly improve initial performance since it wouldn't need multiple requests to get the files (unless you are using http/2 where it wouldn't make that much difference).
Allan