Author Topic: Custom Filtering based on two values/columns  (Read 1766 times)

rsgmedia

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 50
    • View Profile
Custom Filtering based on two values/columns
« on: March 21, 2017, 09:09:49 pm »
Hi PQ Support team,

We have a requirement where we need to filter the data based on two columns/values. We tried to use the existing options from columnModel.filter but not much luck. Here is the scenario...

1. Grid has StartDate & EndDate columns, filtering is enabled on both columns, it shows a date picker.
2. User chooses a date in the StartDate Filter. Let's say the selected date is March 1st, 2017 (03/01/2017).
3. We need to filter the grid rows whose dates are overlapping with 03/01/2017. i.e. rows for which 03/01/2017 is between their StartDate & EndDate.

An example code snippet would be really helpful.

Thanks in advance.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Custom Filtering based on two values/columns
« Reply #1 on: March 22, 2017, 08:55:00 pm »
In the filter listener function

Code: [Select]
listeners: [{ 'change': function (evt, ui) {

var val = ui.value; //e.g., '03/01/2017', user chosen date.

grid.filter({
  data: [
    {dataIndx: 'startDate', condition: 'lte', value: val },
    { dataIndx: 'endDate', condition: 'gte', value: val }
  ]
})

}}]