how to get DT api in ajax.data function with server side

how to get DT api in ajax.data function with server side

johndegeyjohndegey Posts: 6Questions: 2Answers: 1
edited February 2015 in Free community support

Hello,

With server side processing, before sending data in the ajax request, i use a a function to alter the data send.
I would like to send the original column's index... but i can't find a way to obtain the api related to the actual datatable

$('.datatable').DataTable({
            serverSide: true,
            ajax: {
                type: 'POST',
                url: window.location.pathname,
                data: function(data) { // how to have DT.api() ??? }}});

I did not found it in the doc... any idea ?

Thx

John

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,685Questions: 1Answers: 10,500 Site admin

    I don't think there is a way at the moment. An oversight I'll need to look at fixing!

    I don't quite understand what you are looking to do though? The column's index is already sent is it not?

    Allan

  • johndegeyjohndegey Posts: 6Questions: 2Answers: 1

    Hello Allan,

    Yes, the actual index is sent, but i have a problem with yadcf.
    (related to a previous question here : https://datatables.net/forums/discussion/25858/server-side-new-api-statesave-colreorder-and-column-s-order-in-the-xhr-request#latest )

    I use ColReorder, and i would like to send the original index, having something like
    columns[0]['intialIndex'] = 3

    Thx

  • allanallan Posts: 63,685Questions: 1Answers: 10,500 Site admin

    I see. At the moment you would need to use order[].data option that is submitted to the server to reserve the mapping at the server-side. That is what my own examples do. However, I agree it could be useful to access the API in the callback.

    Allan

  • johndegeyjohndegey Posts: 6Questions: 2Answers: 1

    Can you provide a link to your examples because i do not see how you set the initial index in the DT initialization process.

    John

  • allanallan Posts: 63,685Questions: 1Answers: 10,500 Site admin
    Answer ✓

    The initial index is just the HTML order. However, to a large extent in most of my examples it order is irrelevant since it looks up the data name for each column to see what SQL column it belongs to. Example.

    Allan

  • johndegeyjohndegey Posts: 6Questions: 2Answers: 1

    ok, that's what i already use.
    yadcf doesn't work like that right now, it only use the original index...

    Thanks for your reply.

This discussion has been closed.