Using server-side without ajax

Using server-side without ajax

rkrdorkrdo Posts: 2Questions: 0Answers: 0

Hi, first thank you guys for this wonderful grid.
I would like to know if there is a way (possibly a hack) to use datatables server-side without using ajax, I'm using asp.net and because of the arquitecture design of the project I'm working with I need a postback to load the model and gather the data.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Is the postback not Ajax? Do you mean you want to use it without JSON? If so, then no, I'm afraid that is not currently possible in DataTables - it uses JSON as the data carrier.

    If you really need this you could use ajax as a function and write a function that would transform the view into the JSON needed by DataTables, but that seems like quite a lot of work to my mind!

    Allan

  • fkmbkkfkmbkk Posts: 31Questions: 5Answers: 0

    Then you could just use DOM data

  • rkrdorkrdo Posts: 2Questions: 0Answers: 0

    I am getting the data in a C# object that I then serialize to JSON. Right now I'm using client side pagination but need to do server side. The configuration I would like to have is someting like this:
    $('#mainTable').dataTable({
    "serverSide": true, //here i do serialization
    "data": populate()
    //more code });```

    but when I try this I get the invalid JSON error, this is weird since it is the same that works well when not trying server side. I need to get the data from the server but without using ajax. For me it seemed that I just needed to set the data attribute on each page reload, but can not get it working

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    If you get invalid JSON from the server, then you'd need to have a look at what is actually being returned. The tech note the error links to has details showing how to do that.

    Allan

This discussion has been closed.