Serverside Processing - where clause through options?

Serverside Processing - where clause through options?

jandantejandante Posts: 10Questions: 4Answers: 0

Hi,

I know you can alter the ssp.php file to change your where clause. (I only want a part of the data in my table to be shown).

But is it possible to give this where clause through an option when initializing the DataTable?

This way I can keep using the same ssp.php file for all my tables.

Thanks!

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Answer ✓

    You could use ajax.data to set the additional parameters. Your server-side script would need to be modified to accept the additional data and apply it appropriately.

    Allan

  • jandantejandante Posts: 10Questions: 4Answers: 0

    Ok where as the where clause is build you can there receive the ajax.data info and change the code to be added if not null.

    Correct?

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Answer ✓

    Probably if not present (isset() in PHP) rather than null.

    Allan

  • jandantejandante Posts: 10Questions: 4Answers: 0

    Hi @allan,

    for the above question my main concern is that I need all data from a table where client_id = x.

    Adding an extra parameter through ajax.data seems a bit hard + it changes my ssp class which I use for my other tables.

    Now I've managed to do it like this:

     tableContactMoments = $('#tablecontactmoments').DataTable({
    dom: 'rtp',
    iDisplayLength: 5,
    processing: true,
    serverSide: true,
    order: [ 0, 'desc' ],
    ajax: "php/datatables/getTasksPerClient.php",
    columnDefs: [
        {
            targets : [3],
            visible: false
        }
    ],
    searchCols: [
        null,
        null,
        null,
        { search: client_id }
    ],
    language: dutchDataTable
    });
    

    Is this well optimized for the task. Feels like I'm doing a work around.

    Thanks for checking this out!

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

    It is a bit of a workaround since the ajax.data option is designed as the channel for data communication with the server, just like it is in jQuery. However, it if works - that's great :-)

    Allan

This discussion has been closed.