How to send value of start row entry for Ajax paging
How to send value of start row entry for Ajax paging
I am trying to customise the data sent for Ajax paging.
The start parameter passed is the index within the page that the server side needs to generate data for. However the data in my table is a collection of various customer records. So I need to pass the customerid for the "start" row, rather than its index.
i am currently passing the customerid down to the data table and hidding this as the first column. So I have the necessary data in the table. I have also managed to pass a test parameter in the Ajax call by setting the following in the table initialisation:
"ajax": {
"url":"GetAllContactsFilteredTabulation",
"data": function (d) { d.myKey = "xyz" }
},
However i am stuck on populating the test value of "xyz" with the customerid of the row.
I also tried setting the columns in the datatable initialisation but this just passes the name of the column and then the table fails to load the returned information.
I would have thought this would be a fairly standard scenario but have been unable to find anything to help here, in stackoverflow or just googling.
Any help would be appreciated.
This question has an accepted answers - jump to answer
Answers
Ok, a few views but no answers or comments. Given this I will stick with the usual approach of recreating the data source on the backend and then getting the next page required from it.
If someone can point me at the instructions for how to set this this discussion to closed or delete it then I'll do that and put this to rest.
In this case you could use something like:
That will work for server-side processing, but a note for anyone else reading this - it will not always work for client-side processing since the first row visible isn't always the first row in the table (keep in mind that with client-side processing, paging is done at the client-side!).
Allan
Thanks for that Allan. Good point on the client-side I ran into a different aspect of this when I tried to apply a filter on the client side; which obviously will not work! So I am passing up the filter as well as the key and (of course) doing the whole selection, filtering and paging on the server side. At least it makes my client code simple!!