vedmack / yadcf

Yet Another DataTables Column Filter (yadcf)
http://yadcf-showcase.appspot.com/
MIT License
732 stars 285 forks source link

daterangepicker with server side Datatables #606

Open adrienyhuel opened 4 years ago

adrienyhuel commented 4 years ago

"daterangepicker" was added in #537, and this is wonderful :)

But it doesn't works really well with server side Datatables. As it is a "date" filter_type, it send the raw value to ajax (ex : "YYYY-MM-DD - YYYY-MM-DD").

For a range of date, server side expect "YYYY-MM-DD-yadcf_delim-YYYY-MM-DD".

I modified your js this way to make it work :

function "exFilterColumn", case "date" https://github.com/vedmack/yadcf/blob/2c85f071ffcc526b0b93580459a5b00ba0c8167d/src/jquery.dataTables.yadcf.js#L5204

if (optionsObj.datepicker_type == 'daterangepicker') {
    var [min, max] = filter_value.split(" - ");
    table_arg.fnSettings().aoPreSearchCols[column_position].sSearch = min + optionsObj.custom_range_delimiter + max;
} else {
    table_arg.fnSettings().aoPreSearchCols[column_position].sSearch = tmpStr;
}

Do you think it's the right way to make it work ?

vedmack commented 4 years ago

@adrienyhuel what about the case 'range_date': inside exFilterColumn function ?

adrienyhuel commented 4 years ago

@adrienyhuel what about the case 'range_date': inside exFilterColumn function ?

@vedmack the case range_date comes with "filter_type" = "range_date", and it makes two calendars. In order to use the "daterangepicker", we need to use only one field (and that's why in your sample, you put filter_type: "date").