How to send value of start row entry for Ajax paging

How to send value of start row entry for Ajax paging

GAFGAF Posts: 3Questions: 1Answers: 0
edited December 2015 in Free community support

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

  • GAFGAF Posts: 3Questions: 1Answers: 0

    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.

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    edited December 2015 Answer ✓

    In this case you could use something like:

    d.myKey = $('#myTable tbody td:eq(0)').text();
    

    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

  • GAFGAF Posts: 3Questions: 1Answers: 0

    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!!

This discussion has been closed.