server side paging problem

server side paging problem

jnorrisjnorris Posts: 25Questions: 0Answers: 0
edited July 2010 in General
Hi all,

I've been playing around with the plug-in and it looks awesome. I'm having an issue using server side processing (v1.6) where I get an error when selecting the last page. For example, if I'm displaying 10 rows and the last page only has 5 items it causes the javascript error: "'length' is null or not an object jquery.datatables.min.js Line: 207". In the query string sent to the server iDisplayLength is 10 when it seems like it should be 5 in this case. Since there are not 10 more items to return the json data only has 5 rows of data. If I have 30 total items in the data the next/last buttons work. A total number that is not evenly divisible by the iDisplayLength size setting causes the exception.

I searched the forum and didn't come across anything similar. Any suggestions?

Thanks,
Jim

Replies

  • allanallan Posts: 63,205Questions: 1Answers: 10,415 Site admin
    DataTables doesn't really do any logic when dealing with server-side processing - it just says to the server "give me the next 10 records, starting at record x". It is expected that if there are less than ten records available, then the server will reply with less. You can see this in action on the last "page" of the server-side demo: http://datatables.net/examples/data_sources/server_side.html . So just a little logic in the server will do it (the server-side scripts available ( http://datatables.net/development/server-side/ ) all do this.

    Regards,
    Allan
  • jnorrisjnorris Posts: 25Questions: 0Answers: 0
    Hi Allan,

    Thanks for your response. As it turns out I should have also checked the json generated in the border case It turned out that the code on the server placed an extra comma after the last item when the number of items was less than the number to display. Now on to styling issues using jquery ui themes. Sorry to have wasted your time.

    Regards,
    Jim
  • allanallan Posts: 63,205Questions: 1Answers: 10,415 Site admin
    Not at all - good to hear you got it working :-)

    Allan
This discussion has been closed.