The type of the pickergroup should be gridfieldfilterpickergroup and grid should have gantt instance not ganttConfig
I've updated our typescript react basic demo to implement functionality
Please check the attached test case below
You could run by running these commands
$ npm i
$ npm start
Hope this will help
Re: [REACT] Filtering on gantt.
Posted: Mon May 29, 2023 8:54 pm
by umesh
Hi tasnim,
Here's the code of AppConfig.js. The question is how to access the gantt instance inside the change event.
AppConfig.js
import React from 'react';
const ganttConfig = {
project: {
autoLoad: true,
transport: {
load: {
url: 'data/launch-saas.json'
}
},
// This config enables response validation and dumping of found errors to the browser console.
// It's meant to be used as a development stage helper only so please set it to false for production systems.
validateResponse : true,
},
columns: [
{ type: 'name', field: 'name', width: 250, renderer: ({record}) => {
return record.isLeaf ? <span>{record.name}</span> : <b>{record.name}</b>
} },
{
text: 'Start',
type: 'startdate',
width: 80,
},
],
viewPreset: 'weekAndDayLetter',
barMargin: 10,
tbar : [
{
type: 'button',
ref: 'filterAllButton',
icon: 'b-gantt-filter',
tooltip: 'test',
menu: {
pickergroup: {
type: 'fieldfilterpickergroup',
fields: [{ name: 'name', type: 'string', text: 'Name' },{ name: 'status', type: 'string', text: 'Status' },],
filters: [
{
property: 'name',
operator: 'notEmpty',
value: '',
},
],
listeners: {
change: (props) => {
//how to access gantt instance here?
},
},
},
},
},
],
};
export { ganttConfig };
I'm filtering the tasks based on the names. So for names property I need to show only 'contains' operator, but here by default bryntum showing all operators.
Operators.PNG (23.2 KiB) Viewed 360 times
And for other properties also I need only few operators to be displayed but not all. Can we make that operators dropdown customized? If yes, please suggest.
Regards,
Umesh.
Re: [REACT] Filtering on gantt.
Posted: Tue May 30, 2023 1:00 pm
by tasnim
Hi,
You could try to filter out the store of that combo
One challenge with this is making sure to filter at the right times, for example in response to the change event from the filter picker group. You need to refresh the option list every time the property is selected, for example.
Another option would be to extend the filter picker class and override the operatorOptions getter, like this:
class MyFieldFilterPicker extends FieldFilterPicker {
static type = 'myfieldfilterpicker';
get operatorOptions() {
let options = super.operatorOptions;
// your logic here
if (this.filter?.property === 'name') {
options = options.filter(({ value }) => value === 'includes');
}
return options;
}
}
MyFieldFilterPicker.initClass();
class MyGridFieldFilterPickerGroup extends GridFieldFilterPickerGroup {
static type = 'mygridfieldfilterpickergroup';
static childPickerType = MyFieldFilterPicker.type;
}
MyGridFieldFilterPickerGroup.initClass();
Then you would use the type name you defined in your UI, like this:
filterPickers : {
type : 'mygridfieldfilterpickergroup',
So could you please provide me a runnable code such that Name property should have only 'contains' operator and status/owner properties should have 'is one of' operator.
Thanks,
Umesh.
Re: [REACT] Filtering on gantt.
Posted: Wed May 31, 2023 4:05 pm
by marcio
If you follow Emil's custom picker approach, you would need to change the following
get operatorOptions() {
let options = super.operatorOptions;
// your logic here
if (this.filter?.property === 'name') {
options = options.filter(({ value }) => value === 'includes');
} else if (this.filter?.property === 'status' || this.filter?.property === 'owner') {
options = options.filter(({ value }) => value === 'is one of');
}
return options;
}