Sort or Paging

Sort or Paging

fkmbkkfkmbkk Posts: 31Questions: 5Answers: 0

During my ajax call to a function; how do I know it is a Sort or Paging action ?

Cause if its just a paging; then i can skip the sorting call.

Answers

  • fkmbkkfkmbkk Posts: 31Questions: 5Answers: 0

    Any help here ?

  • glendersonglenderson Posts: 231Questions: 11Answers: 29

    If you are using serverSide, please look at the URL or Post elements that are created using F12 of your browser once you click on a page. Everything you need to know is in there. The length, page, filter, sort order, etc. Every button related to a page, every click related to the length, are all passed via the request variables (GET or POST). These elements are present on every ajax action for serverside. If the column based variables are blank or empty, then you know you are not filtering, etc.

    If you are using dataTables natively (that is you loaded your table once via DOM or JSON or Ajax), you don't have to do anything. Datatables does it all for you.

  • fkmbkkfkmbkk Posts: 31Questions: 5Answers: 0

    Yeah...I should investigate the POST first..haha...

    Yeah I am doing server side.. I do not want to waste CPU cycle sorting already sorted list.

    Thanks a lot...

  • ccauchiccauchi Posts: 4Questions: 2Answers: 0
    edited February 2016

    you can use stored procedures to take care of filtering, paging and sorting. that is what i did and its working very smoothly

    the below link can explain better what i have done to get to know what the filtering is, the sorting, page number and also the entries per page:
    https://datatables.net/examples/server_side/

  • fkmbkkfkmbkk Posts: 31Questions: 5Answers: 0

    ccauchi,

    Thanks for your input...for me after retrieving from DB, I will keep it in my session.

    But will explore your idea.

  • fkmbkkfkmbkk Posts: 31Questions: 5Answers: 0

    {"draw":4,"columns":[{"data":"Id","name":"","searchable":true,"orderable":true,"search":{"value":"","regex":false}},{"data":"Name","name":"","searchable":true,"orderable":true,"search":{"value":"","regex":false}},{"data":"Category","name":"","searchable":true,"orderable":true,"search":{"value":"","regex":false}},{"data":"Price","name":"","searchable":true,"orderable":true,"search":{"value":"","regex":false}}],"order":[{"column":1,"dir":"asc"}],"start":5,"length":5,"search":{"value":"","regex":false}}

    This is the Request when I am doing the paging. The "order" is also present there. I have already sorted my list; I do not want to sort it for each paging , to save cpu cycle.

This discussion has been closed.