Hi,
Can I add combo items from the UI, that is, if I have a Text box and a Combo Box, I have to add the text from the Text Box to Combo Box in a Button click event. Is this Possible?
Thanks.
Support Forum
Yeah, Sure.
You can use our built-in components.
Here are the docs reference
https://bryntum.com/docs/gantt/api/Core/widget/Combo
https://bryntum.com/docs/gantt/api/Core/widget/TextField
https://bryntum.com/docs/gantt/api/Core/widget/Button
Here is the sample code of how you can achieve it:
let textField = new TextField({
appendTo : 'container',
placeholder: 'Enter some text',
margin : 20
});
let combo = new Combo({
label : 'Items as strings',
appendTo : 'container',
label : 'Select an item',
margin : 20,
style : { marginRight : '.5em' }
});
new Button({
appendTo : 'container',
text : 'submit',
onClick : () => {
if (textField.value.length > 0) {
combo.store.add({ id : combo.store.allCount + 1, name : textField.value, value : textField.value, text : textField.value });
textField.value = '';
}
},
margin : 20
});
Here is a preview
- Attachments
-
- chrome_VO5a3w8OV7.gif (149.84 KiB) Viewed 103 times