bryntum / support

An issues-only repository for the Bryntum project management component suite which includes powerful Grid, Scheduler, Calendar, Kanban Task Board and Gantt chart components all built in pure JS / CSS / TypeScript
https://www.bryntum.com
54 stars 6 forks source link

Setting Combo items after it has a value does not update the value displayed #4817

Open jsakalos opened 2 years ago

jsakalos commented 2 years ago

When a combo has a value which is not in its dataset initially, for example:

const thisCombo = new Combo({
    items    : [{ value : 'pepsi', text : 'Pepsi' }, { value : 'coke', text : 'Coca Cola' }],
    label    : 'Items as objects',    
    value    : '1',
    appendTo : document.body,
    style    : { marginRight : '.5em' }
});

and then the new items (store data) is set later the displayed value is not updated:

setTimeout(() => {    
  thisCombo.store.data = [
    {value: '1', text:'Hello'},
    { value : 'pepsi', text : 'Pepsi' }, 
    { value : 'coke', text : 'Coca Cola' }
  ];
}, 2000);

The displayed text does not turn into Hello but remains 1.

The workaround could be to call thisCombo.changeValue(thisCombo.value, null) but this is not a real solution. Combo should check its value agains the newly set items and update accordingly.

ExtAnimal commented 2 years ago

This is a Feature Request.

What he wants is to be allowed to set a truly invalid value as the field's value.

The combo has a local store which defines all the valid values. But the value configured in doesn't occur in the store. So it is de facto an invalid value.

He's promising to reload the store later with a new dataset which includes that value, but always allowing the invalid config could be dangerous.

This could be allowable with an allowInvalidValueConfig config (The name being important, it's to allow an invalid value as a configuration, not allowing the user to type an invalid value)

So if that is set, and the value is unmatched, and is from the initial configuration, then cache the value and apply it the next time updateStore is called (at that point there will be a new dataset to match the value against)