datatable server side with deferloader and data ini

datatable server side with deferloader and data ini

marcpiratmarcpirat Posts: 47Questions: 16Answers: 0
edited December 4 in Free community support

I try to use datatable with server side option, but i init table with some value;

Js part

var url = 'http://www.json-generator.com/api/json/get/bXZCNjxHCa?indent=4';

  var table = $('#example').DataTable({
    'processing': true,
    'serverSide': true,
    "deferLoading": 50,
    'ajax': {
      'url': url
    }
  });

Gone an example here
jsfiddle.net/0hczmLxb/

Actually my init data is displayed but when i try to go on next page, I see processing who is displayed... but new data is never displayed.

Answers

  • colincolin Posts: 3,034Questions: 0Answers: 525

    Hi @marcpirat ,

    The problem is that the JSON returned isn't quite right - you're always returning this:

        "recordsTotal": 40, 
        "recordsFiltered": 40, 
        "draw": 1, 
    

    The first page loads only because you had deferLoading enabled, so it gets what's in the table. Disabling that, and adding that 40 record page length, now loads the data - see here.

    Cheers,

    Colin

  • marcpiratmarcpirat Posts: 47Questions: 16Answers: 0

    I search a way to init my table with some data (generated with thymeleaf) and when client click next page to do a call to the server...

    don't know if it's possible

Sign In or Register to comment.