Call search manually

Call search manually

marcpiratmarcpirat Posts: 51Questions: 18Answers: 0

hi

I have a datatable with a custom tool bar who include checkbox

var samplesTestTable = $('#samplesTestsTable').DataTable({
    dom: '<"samples-toolbars">frtip',
    language: {
        "url": urlI18n
    },
    'bLengthChange': false, //hide 'show entries dropdown
    'processing': true,
    'serverSide': true,
    'pagingType': 'simple_numbers',
    'ajax': {
        'type': 'get',
        'url': url,
        'data': function (d) {

            var current = $('#samplesTestsTable').DataTable();
            d.testTypeValue = "[(${testTypeValue})]";
            d.page = (current != undefined) ? current.page.info().page : 0;
            d.size = (current != undefined) ? current.page.info().length : 5;
            d.sort = d.columns[d.order[0].column].data + ',' + d.order[0].dir;
            d.search = d.search.value;
            d.testDoneInclude = $("#testDoneInclude").prop("checked");
        }
    },
    'fnDrawCallback': function (oSettings) {
        $('.dataTables_filter').each(function () {
            $("div.samples-toolbars").html('<div><input type="checkbox" id="testDoneInclude" name="testDoneInclude" class="form-check-input" /><label for="testDoneInclude" class="form-check-label">Test done include</label></div>');
        });
    },
    'columns': [{
            'data': 'id'
        },
        {
            'data': 'buildDate'
        },
        {
            'data': 'productTypesName'
        },
        {
            'data': 'productsName'
        },
        {
            'data': 'supplierName'
        },
        {
            'data': 'machineName'
        },
        {
            'data': 'tests',
            'render': function (data, type, meta) {
                var value = '';
                //loop to get rendered
                for (i = 0; i < data.length; i++) {
                    if (value != '') {
                        value = value + '<br>' + data[i];
                    } else {
                        value = data[i];
                    }
                }

                return value;
            }
        }
    ],
    rowCallback: function (row, data) {
        if (data.nonCompliant) {
            $(row).addClass('nonCompliant');
        }
    }
});

When checkbox value change, I would like to trigger search

$("#testDoneInclude").on('change', function () {
    //call search here
});

Answers

This discussion has been closed.