Using "Absolute sorting" with pagination

Using "Absolute sorting" with pagination

TomAndAnotherDayTomAndAnotherDay Posts: 4Questions: 1Answers: 0

I am using the Absolute sorting plugin to sort a column of data, so that values with 0 end up last.

However, when using pagination, this does not put the 0 rows on the last page at the end.

Is there any way to modify that add-on to allow it to work correctly with pagination?

Answers

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    By pagination do you mean you have server side processing enabled? If so then your server script is responsible for sorting the data and returning the data for that page. The Absolute sorting plugin will work with client side processing only.

    Kevin

  • TomAndAnotherDayTomAndAnotherDay Posts: 4Questions: 1Answers: 0

    Thanks for the response Kevin.

    Yes, I have pagination being handled by the server side. The issue is, when you reverse the order (as in click the header row) it will reverse the order of the data, so the first page then shows all the results that have the zero value, which I would still want at the end.

    It would be overly complicated to then re-order this so that they end up at the end all the time.

    A quicker solution would be to load all the data and then have DataTables handle the pagination on the front end, but I can't see a way of doing this either.

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    A quicker solution would be to load all the data and then have DataTables handle the pagination on the front end, but I can't see a way of doing this either.

    The first question is - do you need server side processing? See this FAQ. Do you have performance issues without server side processing?

    It would be overly complicated to then re-order this so that they end up at the end all the time.

    If you are using a SQL DB maybe something like the query in this [thread(https://dba.stackexchange.com/questions/154814/how-to-return-rows-with-a-specific-value-last) would work.

    Kevin

  • TomAndAnotherDayTomAndAnotherDay Posts: 4Questions: 1Answers: 0

    i currently only have around 800 records so I can potentially load all items in and then paginated them on the front end if that is possible?

    I'm using Eloquent, but yes there would be a way to do the sorting. I'm just not sure how I would do that when the order is reversed at the moment. I need to understand more about how DataTables does it's fetching.

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923
    edited July 2020

    i currently only have around 800 records so I can potentially load all items in and then paginated them on the front end if that is possible?

    Try commenting out serverSide: true. Your server script might return all rows if it doesn't see the server side protocol. 800 should be fine for client side processing.

    I need to understand more about how DataTables does it's fetching.

    The Server Side docs explain the protocol used. Are you using a Datatables provide server side script?

    Kevin

  • TomAndAnotherDayTomAndAnotherDay Posts: 4Questions: 1Answers: 0

    We had to pause this while we worked on other features. I will post a solution once we have one for the future benefit of others. At the moment, our current plan is to re-write our server side to code do the necessary reordering based on what's passed through from the front end.

    So we will essentially split our data into 2 separate arrays, the first being the data without the values that we want at the end and then the second is the remaining data.

    We will then do all our sorted based on the first set of data, and then stitch the rest on to the end.

This discussion has been closed.