How reload a datatable after getting new data (ajax - query on remote db with filters on x columns)?

How reload a datatable after getting new data (ajax - query on remote db with filters on x columns)?

flefeverflefever Posts: 1Questions: 1Answers: 0
edited April 2019 in Free community support

I use ajax+json to show a table with data of the result of a query on a mysqli-database on a server:

$(document).ready(function() {
    personenDataTable = $('#personenTable').dataTable({
        bProcessing: true,
        bServerSide: true,
        iDisplayLength: 25, 
        aLengthMenu: [[25, 50, 200, -1], [25, 50, 200, "Alles"]],   
        sAjaxSource: 'personen.php?command=searchPersonen',
        sPaginationType: 'full_numbers',
        aoColumnDefs: personenDataTable_aoColumnDefs,
        aaSorting: [[27,'desc']]
    });

When i fill some text in the "search" field there will be a new query for each character entered.
This works fine.
However i wish to have a filter on different columns, i find exemples of how to filter on more than 1 column but these are filters on the data allready received, is there an exemple of a datatable with data coming via ajax-source and filters on more then 1 column defined in the sql-querystatement?

Answers

  • colincolin Posts: 15,146Questions: 1Answers: 2,586

    Hi @flefever ,

    If you mean input elements like this, then that can work with serverSide, as the server will do the filtering on that string. If you want something like these dropdowns, you'll need to have an additional ajax request to get the complete list of options.

    Cheers,

    Colin

This discussion has been closed.