Paging or sorting?

Paging or sorting?

GooDGreYGooDGreY Posts: 7Questions: 0Answers: 0
edited December 2013 in General
I apologize in advance for my English.
My question:
[code]
$ ("# example"). dataTable ({
                     "bProcessing": false,
                     "bServerSide": true,
                     "sAjaxSource": "Handler.ashx"
});
[/code]
On the server, I need to know if there is paging. How do I determine? I would like something like this:
 [code] "fnServerParams": function (aoData) {
if (_something_){
   aoData.push ({"name": "paging", "value": "true"});
}
}
[/code]
Thanks!

Replies

  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin
    edited December 2013
    You could use the iDisplayLength, parameter that is sent to the server. It should be -1 if there is no paging.

    Allan
  • GooDGreYGooDGreY Posts: 7Questions: 0Answers: 0
    edited December 2013
    No, iDisplayLength is always > 0.
    Sorting and pages always goes to the server, regardless of the action = /
    I fell in love with your product, but I really need to recognize the paging :)
    My form data:

    sEcho:4
    iColumns:33
    sColumns:
    iDisplayStart:10000
    iDisplayLength:5000
    mDataProp_0:0
    -
    mDataProp_32:32
    iSortCol_0:1
    sSortDir_0:asc
    iSortingCols:1
    bSortable_0:true
    -
    bSortable_32:true
  • GooDGreYGooDGreY Posts: 7Questions: 0Answers: 0
    edited December 2013
    For a while I solved the problem like this, but I do not like it
    [code]
    "fnServerParams": function (aoData) {
    var isPaging = false;
    var beforePageStart = localStorage.getItem('pageStart');
    var afterPageStart = oTable.fnSettings()._iDisplayStart.toString();
    if (localStorage.getItem('pageStart'))
    isPaging = beforePageStart != afterPageStart;
    aoData.push({ "name": "isPaging", "value": isPaging });
    localStorage.setItem('pageStart', oTable.fnSettings()._iDisplayStart);
    [/code]
  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin
    It seems to work just fine for me here: http://live.datatables.net/avaqax/edit#javascript,html . Please link me to a test case showing it not working, so if there is a problem in DataTables I can fix it.

    Allan
  • GooDGreYGooDGreY Posts: 7Questions: 0Answers: 0
    edited December 2013
    Excuse me, we still do not understand each other. I need paging, just when a request comes in to the server I need to know what action had been produced. Sorting, paging, or simply download the table.
    p.s. im russian, google translate helps me, but not always :)
  • GooDGreYGooDGreY Posts: 7Questions: 0Answers: 0
    edited December 2013
    In the example above, I retain the current page and if it is changed, I know that the user changes the page.
  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin
    I'm a bit confused then. DataTables cannot change mode based on the Ajax return from the server. It is either server-side processing, or it is client-side processing. There can be no mix of the two nor can it dynamically change between them. It can only be selected at initialisation time. So if you need to change it based on the data, you need to do the Ajax get yourself.

    Allan
  • GooDGreYGooDGreY Posts: 7Questions: 0Answers: 0
    edited December 2013
    Here is your example http://datatables.net/release-datatables/examples/server_side/server_side.html. Okay? When the data arrives at the server, how do you know which button the user has clicked (sorting or paging)? Just know, without any action
  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin
    You don't. There is nothing in the public interface that DataTables exposes that would give that information. If you need it, you would need to modify DataTables.

    Allan
  • GooDGreYGooDGreY Posts: 7Questions: 0Answers: 0
    Thanks
This discussion has been closed.