aslagle / reactive-table

A reactive table designed for Meteor
https://atmospherejs.com/aslagle/reactive-table
Other
328 stars 137 forks source link

Simultaneously multiple filter not working #368

Closed sakshi-kataria closed 8 years ago

sakshi-kataria commented 8 years ago

'change #duration' : function(event, template){ template.filter = ReactiveTable.Filter('durationRpt', ["time"]); var input = $(event.target).val(); if (!_.isNaN(input)) { if(input === '1'){ template.filter.set({$gt:[new Date(Date.now() - 24_60_60_1000)]}); }else if(input === '7'){ template.filter.set({$gt:new Date(Date.now() - 7_24_60_60_1000)}); } else if(input === '30'){ template.filter.set({$gt:new Date(Date.now() - 30_24_60_60*1000)}); }

  } else {
    template.filter.set({$gt:new Date(Date.now() - 24*60*60*1000)});
  }
}

'change #DrpStatus' :function (event, template){ template.filter = new ReactiveTable.Filter('actionRpt', ["action"]); var input = $(event.target).val(); if (!_.isNaN(input)) { if(input=='all') { template.filter.set({$in:['offline','online']}); } else { template.filter.set(input); } } else { template.filter.set(""); } } }

'change #DrpTerminal' : function(event, template){ template.filter = new ReactiveTable.Filter('terminalRpt', ["terminalId"]); var input = $(event.target).val(); if (!_.isNaN(input)) { if(input=='all') { template.filter.set(""); } else { template.filter.set(input); } } else { template.filter.set(""); } }

tableSettingsTerminals: function() { return { rowsPerPage: 20, showFilter:false, filters:['actionRpt','terminalRpt','durationRpt'],

If i am applying three filter than on dropdown change that filter is applied another 2 are lost...

aslagle commented 8 years ago

If all the filters are in the same template, you need to use different variable names for each of them, like template.actionRptFilter, template.durationRptFilter, instead of template.filter for all of them. Otherwise all of your events will change the same filter.