Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do custom filtering with Datatables and server-side processing

I am using Datatables to display tabular data in my Web application, and have configured it to make use of server-side processing, i.e. query the server via AJAX for filtered data. I want to filter according to additional parameters that are specific to my application, i.e. corresponding to some user options (f.ex. via a checkbox in the UI). How do I make DataTables pass these additional filter parameters to the server?

like image 497
aknuds1 Avatar asked Nov 30 '12 11:11

aknuds1


1 Answers

Dynamic parameter, This one is working for me, seems best solution

t = $("#tbl_SearchCustomer").DataTable({
    processing: true,
    serverSide: true,
    info: true,
    ajax: {
        url: '../Data/SearchCustomer',
        data: function (data) {
            data.CustomerCategoryID = $("#CustomerCategoryID").val(); // dynamic parameter
            delete data.columns;
        }
    },
    deferRender: true,
    columns: [
        { "data": "FullName" },            
    ],       
    dom: 'lfrtip'
});
like image 68
Arun Prasad E S Avatar answered Sep 28 '22 04:09

Arun Prasad E S