make only sorting by ajax request and first rendering without
make only sorting by ajax request and first rendering without
guy490
Posts: 3Questions: 1Answers: 0
Hi,
I want to create table that I will render the data when the page loading but without ajax,
and only when the user try to do paging or sorting, it will do ajax to update it.
now when I do "serverSize: true", also the loading of the table is act by ajax.
Answers
Do you mean
serverSide
?It sounds like what you are looking for is
deferLoading
- see the example here.It is worth noting that this property is deprecated and will be removed in v2 (it was hardly ever used).
Allan
Sorry, yes "serverSide".
and you say its deprecated?
but there is no replacement to this?
on the first load, I want to display user the data, but after user interation to make this ajax request.
No - no replacement since it is so rarely used, and its main reason for existing is no longer an issue. I added it way back before search engines executed Javascript and Ajax requests, and thus wouldn't index the data. They do now and Ajax requests are so fast that the load time before the end user sees the data is very low (depending on the server-side service of course).
The other issue is the duplication of rendering - with this feature you need to create an HTML table that shows the first page of data for the DataTable without DataTables doing any of its rendering (data formatting, etc). This gets really messy if you use state saving, an initial search or anything else that effects the display of the data.
So it is totally possible, you can use
deferLoading
and create the HTML for your first page of data, but in the majority of cases it just isn't worth the extra development effort - hence why it is rarely used and being dropped in v2.Do you have a use case for it that I've not thought of?
Allan
My case is not so common.
I already have a controller of the page that load data and html when the page is loading, it builds the html and then I'm calling the datatable, so my case is in the first loading the table has the information to load and on the sorting or page change we have different controller that handle it.
It sounds like you might have a table control already then - do you need DataTables on top of it? Does it do paging, etc already? I don't want to dissuade you from using DataTables(!), but having two different table controls trying to control the same table sounds like bad news.
Allan