Our state of the art Gantt chart


Post by awendt »

I have added the following config for the duration column on my gantt chart:

                
{ id: 'duration', type: 'duration', filterable: { filterFn : ({ record, value, operator, property }) => { const result = new DurationFilter(record[property]._magnitude, value._magnitude).compareAsIntegers(operator) return result } }, }

As you can see, I added a filterFn to override the default filtering and following the pattern described in your documentation here: https://bryntum.com/docs/gantt/#Grid/column/Column#config-filterable

The problem that I am having is that the incoming value for the 'operator' variable is always the same after the first time I use the filter. So if I load the page and set the filter to 'equals 4' the operator is '=' (which is correct and expected) but then if I change the filter to 'less than 4' the operator still comes into the filterFn as '=' even though it should be '<'. That remains the case until I reload the page. Once I reload I can set the filter to 'less than 4' and the operator is '<' but then if I try to filter on 'equals 4' then the operator still comes in as '<'.

I have believe I have tracked the issue down to line 945 of 'Grid/feature/Filter.js' which looks like this:

               
// Cache CollectionFilter on the column to not have to recreate on each filter operation if (!column.$filter) { column.$filter = new CollectionFilter({ columnOwned : true, property : filter.property, operator : filter.operator, value : filter.value, filterBy(record) { return column.filterable.filterFn({ value : this.value, record, operator : this.operator, property : this.property }); } }); }

I believe that it is the caching that is causing the issue. The operator is getting cached so even if the operator really has changed the operator passed to column.filterable.filterFn will never change until the page is refreshed and column.$filter is no longer cached.


Post by pmiklashevich »

Thanks for the report! Ticket here: https://github.com/bryntum/support/issues/2856

Pavlo Miklashevych
Sr. Frontend Developer


Post Reply