Our blazing fast Grid component built with pure JavaScript


Post by vadim_g »

Hi guys,

I think this is a bug, the combo.value should be taken as the record id (as per Model's default and Combo config) and name also, and be set accordingly. Instead it does not set the value as id but only as name and generates new id.

https://codepen.io/Vadim-Popa/pen/QwydYoN

Thanks
Vadim


Post by vadim_g »

The same for this test case (Related to https://github.com/bryntum/support/issues/11781)

		const comboValue = ['first'];

		const comboCfg = {
			appendTo: document.body,
			label: 'Local Combo',
			multiSelect: true,
			value: comboValue,
			valueField: 'id',
			createOnUnmatched: true,
			width: 400,
			height: 60,
		};

		combo = new ComboBox(comboCfg);

              // Fails: ['_generatedModelClass_534fb73c-8f43-4107-9b14-e1c282e0498c'] != ['first']
		expect(combo.value).to.be.eq(comboValue); 

Post by alex.l »

Hi Vadim,

This is misconfiguration. Actually for the case when you set displayField/valueField, value is expected to be an Object/model instance with the structure you configured. In case you don't have values in store that might be found by id provided.
When it has not been found, a new model instance created. We decide if we can use typed value as displayField or valueField and use it as displayField, otherwise we have to limit the text entered because not all might be used as model id value.
Correct way to add new value with result you expected should be

combo.value = { id : 1, text : 'Numero Uno' }

If you want to have value as typed. do not specify model fields as displayField/valueField.

All the best,
Alex Lazarev

How to ask for help? Please read our Support Policy

We do not write the code in bounds of forum support. If you need help with development, contact us via bryntum.com/services


Post by vadim_g »

Hi Alex,

I'm interested in the case when the valueField is set. And, that makes sense of course, the typed value in Input is used as displayField (and valueField as well), it is correct behaviour.

But question here is about the value that is set programatically. And the value can be set in 2 ways:

  1. As a record/data record, as you wrote: combo.value = { id : 1, text : 'Numero Uno' } , then if I read back the combo.value it should be the valueField, so if valueField: 'id', in this case it should be combo.value === 1;
combo.value = { id: 1, text: 'Numero Uno' };
expect(combo.value).to.equal(1);
  1. As a valueField, thus combo.value = 1;. So again, it should be combo.value === 1;;
    combo.value = 1;
    expect(combo.value).to.equal(1);

Then, the Model by default has the idField: id, so in this case the record id should not be generated but used from given combo.value, or from Input if is typed.

If I set valueField: 'text' then the combo.value===1. But from conceptual point of view, it should work with valueField: 'id' too. And in both cases, the record id is generated, but it should not, it should combo.selected.get('id') === 1

Vadim


Post by alex.l »

Hi Vadim,

Thank you!
We discussed this with the team, we will fix default behaviour. You can find workaround in a ticket if required
https://github.com/bryntum/support/issues/11984
You can subscribe on ticket updates to be notified when it's done.

All the best,
Alex Lazarev

How to ask for help? Please read our Support Policy

We do not write the code in bounds of forum support. If you need help with development, contact us via bryntum.com/services


Post by vadim_g »

Great, minor one, good to have it fixed.

Thanks
Vadim


Post Reply