Page 1 of 1
[REACT] How to get the selected value from Combo (dropdown) widget in the toolbar
Posted: Tue Sep 27, 2022 11:28 am
by radhakrishnan.y
Hi
Am using the below code to get the user selected value from combo
{
type : 'combo',
label : 'View By',
editable : false,
width : '20em',
displayField : 'name',
value : 1,
store : {
data : [
{
id : 1,
name : 'Unit',
},
{
id : 2,
name : 'Feature',
}
]
}
}
Re: [REACT] How to get the selected value from Combo (dropdown) widget in the toolbar
Posted: Tue Sep 27, 2022 12:02 pm
by tasnim
You can use https://bryntum.com/docs/gantt/api/Core/widget/Combo#event-select event to get the selected value.
It is gonna fire when an item is selected.
{
type : 'combo',
label : 'View By',
editable : false,
width : '20em',
displayField : 'name',
// code below
listeners : {
select(event) {
console.log(event.record);
}
},
value : 1,
store : {
data : [
{
id : 1,
name : 'Unit',
},
{
id : 2,
name : 'Feature',
}
]
}
}
Re: [REACT] How to get the selected value from Combo (dropdown) widget in the toolbar
Posted: Tue Sep 27, 2022 1:20 pm
by radhakrishnan.y
Thanks it is working.
How do I load new JSON data into task after I selected the dropdown
Re: [REACT] How to get the selected value from Combo (dropdown) widget in the toolbar
Posted: Tue Sep 27, 2022 2:31 pm
by tasnim
Hi,
... load new JSON data into task ...
Sorry, I don't understand what you mean by that. Could you please explain a bit further?
Re: [REACT] How to get the selected value from Combo (dropdown) widget in the toolbar
Posted: Tue Sep 27, 2022 2:45 pm
by radhakrishnan.y
After the dropdown is selected, We have to get all the task data from the this.gantt and do some manipulation and feed it again to this.gantt
Re: [REACT] How to get the selected value from Combo (dropdown) widget in the toolbar
Posted: Tue Sep 27, 2022 3:14 pm
by tasnim
Here is an example of how you can load it.
{
type : 'combo',
ref : 'projectSelector',
label : 'Choose project',
editable : false,
width : '20em',
displayField : 'name',
value : 1,
store : {
data : [
{
id : 1,
name : 'Launch SaaS',
url : '../_datasets/launch-saas.json'
},
{
id : 2,
name : 'Build web app for customer',
url : '../_datasets/tasks-workedhours.json'
}
]
},
listeners : {
select({ record }) {
this.gantt.project.load(record.url);
}
}
}