Radoslav Trenev
Radoslav Trenev

Reputation: 373

yadcf range_date filter always returns empty value

I have this datatable and i'm trying to use YADCF to filter my results. The table works fine and the filter UI loads perfectlly, but when i select a date, it filters all results and even when i delete the selection, the 'filter' stays applied until i refresh the page. This bug applies to all yadcf filters, not only range_date.

  $(document).ready(function() {
    var active = $('#active').DataTable( {
        global: false,
        "dom": 'f<"toolbar">rtilp',
        "processing": true,
        "serverSide": true,
        "ajax": {
            "url": "processing_active.php"
        },

        "order": [[ 4, "desc" ]]',[ 2, "asc" ],[ 10, "desc" ]],
        "deferRender": true,
        "lengthMenu": [[55, 155, 250, -1], [55, 155, 250, 'All']],
        "columns": [
        {
            "class":          "details-control",
            "orderable":      false,
            "data":           null,
            "defaultContent": "",
            "visible":        false
        },
        { "data": "loadNumber","width": "8em"},
        { "data": "driverName","width": "10em"},
        { "data": "truckNum","width": "5em"},
        { "data": "puDate","width": "9em"},
        { "data": "puCity", "width": "10em"  },
        { "data": "puState", "width": "1em" },
        { "data": "regStatus"},
        { "data": "deCity", "width": "10em" }, 
        { "data": "deState", "width": "1em"}, 
        { "data": "deDate","width": "9em"},
        { "data": "loadRate","width": "7em"},
        { "data": "confNumber", "width" : "9em"},
        { "data": "dispatcherName", "width": "10em"},
        { "data": "smallStatus"}
        ]
    });
     $(document).ready(function() {     
        $('#active').dataTable().yadcf([

                    {
                    column_number: 4,
                    filter_type: "range_date",
                    }
        ]);

    });

Upvotes: 0

Views: 1538

Answers (2)

Daniel
Daniel

Reputation: 37061

You need to write the filtering logic on your server side, because when using datatables with server side processing all your filtering logic is done on the server too, you need to parse the columns[0][search][value] / columns[1][search][value] / etc and return only relevant rows back to the client,

You can use the github to try and find some relevant example using yadcf and php, here a possibly search query on github

p.s you really should use the following syntax to init yadcf, in the first ready block of your code just after constructing datatables, call the following code

yadcf.init(active,.....

Upvotes: 1

Tomanow
Tomanow

Reputation: 7377

Try this instead for your yadcf:

yadcf.init(active, [{
    column_number:       4,
    column_data_type:    'text',
    filter_type:         'range_date'
}]);

Upvotes: 0

Related Questions