Yadcf Datatables custom function, show 7 days ago
Yadcf Datatables custom function, show 7 days ago
pcpacino2141
Posts: 11Questions: 5Answers: 0
I need to create a custom function for a select filter using yadcf. I have date fields in column with the format 11/19/2018. I need to create a select filter with the values: last 7 days, last 15 days, next 7 days, next 15 days. I need help creating this. I have this so far.
{
column_number : 0,
filter_container_id: 'external_filter_container_0',
filter_type: 'custom_func',
custom_func: myCustomFilterFunction,
data: [{ value: 'last 7 days', label: 'last 7 days'}, { value: 'last 15 days', label: 'last15 days'}, {
value: 'next 7 days', label: 'next 7 days'}, { value: 'next 15 days', label: 'next 15 days'}],
filter_default_label: "Custom func filter"},
function myCustomFilterFunction(filterVal, columnVal) {
var date = currentdate
var cutofftime = parseDate(aData[0]);
switch (filterVal) {
case 'last 7 days':
found = columnVal.search date through -7
break;
This discussion has been closed.
Answers
or this
var backdate1 = getDate(-7)
var backdate2 = getDate(-15)
var futuredate1 = getDate(+7)
var futuredate2 = getDate(+15)
switch (filterVal) {
case 'last 7 days':
if (backdate1 <= getDate() end) {
break;
case 'last 15 days':
if (backdate2 <= getDate() end) {
break;
Hi @pcpacino2141
This thread here shows how to create a range search. I'd suggest using Moment.js to deal with dates, it makes like much easier.
Cheers,
Colin
Hi Colin, Is the link to the thread correct? I only see a Datatable example and momentjs is not even attached in the example. Thanks, Paul
Ah, yep, it should have been this: http://live.datatables.net/sefidika/1/edit
That's not a date search, just an example of how you can do ranges. Likewise here.
Cheers,
Colin
Thank you Colin, I will try that method.