External form filter with jquery datatables

Asked

Viewed 385 times

1

I am trying to make an external filter from an external form

Until then, for a simple generic search, jquery datatables use the parameter 'sSearch'

For that, I just do

  var grid = new $.fn.dataTable.Api('.e-grid');
  grid.search('Teste');
  grid.draw();

All right, but I need to make a slightly more complex filter, which the filter form data is not in the column. I say this, because every filter a little more complex that I found of example, was only of the columns that already existed in datatable

The question is, how do I pass other parameters to that filter? other than the default which is sSearch

OBS: The filter is via Ajax, and how Server Side I am using Asp.net MVC

1 answer

1

Follow an example below:

var oTable = $("#dataTableCustom").dataTable({
        "iDisplayLength": 25,
        "bDestroy": true,
        "bProcessing": true,
        "bJQueryUI": true,
        "bAutoWidth": false,
        "bServerSide": true,
        "sAjaxSource": globalSource,
        "sPaginationType": "full_numbers",
        "fnServerData": function (sSource, aoData, fnCallback) {
            $.getJSON(sSource, aoData, function (json) {
                var parsedJSON = $.parseJSON(json);
                fnCallback(parsedJSON)
            });
        },
        "fnServerParams": function (aoData) {
            aoData.push({
                "name": "listName",
                "value": wcfListName
            })
            aoData.push({
                "name": "columnNames",
                "value": wcfColumnsToDisplay
            })
            aoData.push({
                "name": "SortingDirection",
                "value": wcfSortDirection
            })
            aoData.push({
                "name": "sortingColumns",
                "value": wcfSortColumns
            })

        }
    });

The value of "value" can also be an imput, ex:

"value": $(".meuiinput").val();

The above example was taken from this LINK, of the world of Jquery DataTables

Browser other questions tagged

You are not signed in. Login or sign up in order to post.