Skip to content

Date custom filter on reactive table collection not working #489

Description

@Abhimanyu-Jana

I have a reactive-table with custom filter defined on a date column


Template.displayoptions.created = function () {
    this.timeFilter = new ReactiveTable.Filter('time-filter', ['deadline']);
};

Template.displayoptions.events({
'click .form-check-input'(event,template) {
    var timefilter = template.find('#timefilter:checked').value;

    var today = new Date();
    var thisweek = new Date(moment(today).add(7, 'days'));
    var thismonth = new Date(moment(today).add(1, 'month'));

    switch(timefilter){
        case "today":
            template.timeFilter.set({"$gte": today});
            break;
        case "thisweek":
            template.timeFilter.set({"$and":[{"$gte": today}, {"$lt" : thisweek}]});
            break;
        case "thismonth":
            template.timeFilter.set({"$and":[{"$gte": today}, {"$lt" : thismonth}]});
            break;
    }        


}

});

When the event is triggered (radio button to select today/week/month), the table flashes but data remains unchanged.
What could be missing?

rowsPerPage: 5,
filters: ['time-filter'],
showNavigationRowsPerPage: false,
showFilter: false

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions