Filtering Option "Datetime is not Defined"

Filtering Option "Datetime is not Defined"

zgoforthzgoforth Posts: 482Questions: 91Answers: 2

Link to test case: https://jsfiddle.net/BeerusDev/mznL52p8/144/

So originally, I had created a plugin to filter the table to only show data that contained dates in that of the current week. Here it is:

$.fn.dataTable.ext.search.push(
    function( settings, searchData, index, rowData, counter ) {
        var now = moment();
        var monday = now.clone().weekday(1);
        var friday = now.clone().weekday(5);
        
        let mondayF = monday.format('MM/DD/YYYY');
        let fridayF = friday.format('MM/DD/YYYY');
        
        
        var sMonday = searchData[2];
        var sFriday = searchData[10];
        
        if (mondayF == sMonday && fridayF == sFriday) {
            return true;
        }
        return false;
    }
);

It worked perfectly, but unfortunately requirements changed and now I need to be able to filter through all the data, especially so people can look back at past weeks.

I implemented https://datatables.net/extensions/datetime/examples/integration/datatables.html, and it is giving me quite a bit of errors, as well as the calendar/date selector appear below the table? Lastly, the example searches for a value from one column, I want to find a couple of dates from the Monday-Friday columns. Like if they are in between the Monday & Friday Dates, show it.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 12,939Questions: 0Answers: 2,204
    Answer ✓

    DateTime is now it's own independent library, so you'll need to import those files into your app too. Alternatively, just use the Download page,

    Colin

  • zgoforthzgoforth Posts: 482Questions: 91Answers: 2

    @colin thanks I forgot to add the stylesheet as well as the script... I made sure to include those, and look at how the Date Range Filter selector is below the table, and nothing happens when I enter the two dates to search for, the table doesn't filter. Meanwhile, nothing is happening in console showing me any warnings or errors:
    https://jsfiddle.net/BeerusDev/mznL52p8/150/

Sign In or Register to comment.