Symfony 4 Sorting not working with large amount of entries

Symfony 4 Sorting not working with large amount of entries

chefigueroachefigueroa Posts: 3Questions: 1Answers: 0

For my DataTable, every column is configured to sort( 'orderable' => true). When you click on the column it successfully sorts the column. For some reason when there is an extremely large amount of entries, for example over 10,000, it doesn't sort. I was told it can't be a timeout error because I am using an ajax DataTable(meaning it doesn't pull all the data to the client side at once, instead it makes an ajax request returning only the visible items as you paginate). I am looking for some sort of error message in the console and network tabs of the devtools, but no errors popped up. Is there something I am missing or need to look at?

Answers

  • kthorngrenkthorngren Posts: 20,269Questions: 26Answers: 4,765

    When you say paging I think you are referring to server side processing (serverSide: true) in your Datatables initialization code. If this is the case then its up to your server code to sort the data and return the correct page of data. You will need to look at the server script to see why its not sorting correctly.

    Kevin

  • chefigueroachefigueroa Posts: 3Questions: 1Answers: 0

    You mentioned:
    "If this is the case then its up to your server code to sort the data and return the correct page of data."

    I have configured my server side script to sort: 'orderable' => true

    It works, but it doesn't work when I have a large amount of entries, 10,000 for example.

    That is my problem: sorting doesn't work for a large amount of entries. In my case, over 10,000 entries.

  • kthorngrenkthorngren Posts: 20,269Questions: 26Answers: 4,765

    Is your server script a Datatables provided script or are you using your own?

    Does your server script use something like SQL's Limit and Offset to limit the number of rows returned in the query?

    Kevin

  • chefigueroachefigueroa Posts: 3Questions: 1Answers: 0

    I am getting all the rows returned in the query. Getting the rows isn't the problem. The problem is being able to sort the rows when I have 10,000+ entries.

  • kthorngrenkthorngren Posts: 20,269Questions: 26Answers: 4,765

    I am getting all the rows returned in the query.

    Does this mean you are getting 10,000+ rows or just the rows for the page being displayed?

    The problem is being able to sort the rows when I have 10,000+ entries.

    What happens? Do you get errors?

    Based on your questions and responses, until your last response, I assumed your are using Server Side Processing - you have serverSide: true in your Datatables config. Is this correct?

    Can you provide a link to your page so we can take a look at what you have and see what is happening?

    Kevin

This discussion has been closed.