Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date custom filter on reactive table collection not working #489

Open
Abhimanyu-Jana opened this issue Aug 3, 2018 · 2 comments
Open

Date custom filter on reactive table collection not working #489

Abhimanyu-Jana opened this issue Aug 3, 2018 · 2 comments

Comments

@Abhimanyu-Jana
Copy link

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
@Abhimanyu-Jana
Copy link
Author

I just read that and/or do not work in custom filters. However the 'today' filter also does not work which has no logical operators defined.

@Abhimanyu-Jana
Copy link
Author

Some more info:

The collection is published with existing filter on the date column on server side.
Date is stored as date object in mongo, but displayed as YYYY-MM-DD in table.

fn: function(value){ return moment(value).format('YYYY-MM-DD');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant