Datatables custom filtering with server side

后端 未结 2 992
谎友^
谎友^ 2021-01-04 13:46

I\'m using DataTables and also using server side processing (Django).

I have a seperate textfield in which I use it to custom filter data in the DataTable after the

2条回答
  •  花落未央
    2021-01-04 14:20

    Here is a very nice explanation on how to do it: https://datatables.net/reference/option/ajax.data

    I am currently using this code:

    "ajax": {"url":"/someURL/Backend",
            "data": function ( d ) {
                      return $.extend( {}, d, {
                        "parameterName": $('#fieldIDName').val(),
                        "parameterName2": $('#fieldIDName2').val()
                      } );
            }
    }
    

    You call it by doing the following:

    $('#myselectid').change(function (e) {
            table.draw();
    });
    

    If you want to submit by clicking on the button, change the .change to .click and make sure that ID is pointing to button's id in a HTML

提交回复
热议问题