-
Bug
-
Resolution: Fixed
-
Major
-
None
-
None
-
None
-
4.8.0 M10
In a AbstractQueryableComboBox widget, idProperty of the combobox store have to be equals to valueField property. Otherwise #setValue does not work.
Indeed, in #setValue, we use me.combobox.getStore().getModel().idProperty instead of me.valueField
setValue: function (value) { var me = this; value = Ext.isEmpty(value) ? [] : Ext.Array.from(value); // Values can be either String (of id) or the model var ids = []; Ext.Array.each(value, function(v) { if (Ext.isString(v)) { ids.push(v); } else { ids.push(v[me.combobox.getStore().getModel().idProperty]); me.combobox.getStore().add(v); } }); me.callParent([ids]); me.combobox.setValue(ids); }
Model of combobox store and valueField/displayField should be independant.
Sample of case, the SelectEducationalPath widget (ODF) does not work with following configuration. It should have.
Ext.define('Ametys.odf.widget.SelectEducationalPath', { extend: 'Ametys.form.AbstractQueryableComboBox', valueField: 'id', displayField: 'title', getStore: function() { if (!Ext.data.schema.Schema.get('default').hasEntity('Ametys.odf.widget.EducationalPath')) { Ext.define("Ametys.odf.widget.EducationalPath", { extend: 'Ext.data.Model', idProperty: 'value', fields: [ {name: 'value', type: 'string'}, {name: 'id', type: 'string'}, {name: 'title', type: 'string'} ] }); } return Ext.create('Ext.data.Store', { model: 'Ametys.odf.widget.EducationalPath', proxy: { type: 'ametys', methodName: 'getEducationalPathsEnumeration', methodArguments: ['programItemId'], role: 'org.ametys.odf.ODFHelper', reader: { type: 'json' } }, sorters: [{property: 'title', direction:'ASC'}], listeners: { beforeload: {fn: this._onStoreBeforeLoad, scope: this} } }); }
[RUNTIME-4000] Unable to use a idProperty and valueField different for a AbstractQueryableComboBox widget
Status | Original: Resolved [ 5 ] | New: Closed [ 6 ] |
Resolution | New: Fixed [ 1 ] | |
Status | Original: Ready to merge [ 10208 ] | New: Resolved [ 5 ] |
Assignee | New: Laurence Aumeunier [ laurence ] |
Status | Original: Functional review OK [ 10207 ] | New: Ready to merge [ 10208 ] |
Status | Original: Available for review [ 10005 ] | New: Functional review OK [ 10207 ] |
Sprint | New: 4.8.0 M10 [ 95 ] |
Fix Version/s | New: 4.8.0 [ 17980 ] |
Status | Original: Open [ 1 ] | New: Available for review [ 10005 ] |
Description |
Original:
In a AbstractQueryableComboBox widget, idProperty of the combobox store have to be equals to {{valueField}} property. Otherwise #setValue does not work.
Indeed, in #setValue, we use {{me.combobox.getStore().getModel().idProperty}} instead of {{me.valueField}} {code} setValue: function (value) { var me = this; value = Ext.isEmpty(value) ? [] : Ext.Array.from(value); // Values can be either String (of id) or the model var ids = []; Ext.Array.each(value, function(v) { if (Ext.isString(v)) { ids.push(v); } else { ids.push(v[me.combobox.getStore().getModel().idProperty]); me.combobox.getStore().add(v); } }); me.callParent([ids]); me.combobox.setValue(ids); } {code} Model of combobox store and valueField/displayField should be independant. Sample of case, the SelectEducationalPath widget (ODF) does not work with following configuration. It should have. {code} Ext.define('Ametys.odf.widget.SelectEducationalPath', { extend: 'Ametys.form.AbstractQueryableComboBox', valueField: 'id', displayField: 'title', getStore: function() { if (!Ext.data.schema.Schema.get('default').hasEntity('Ametys.odf.widget.EducationalPath')) { Ext.define("Ametys.odf.widget.EducationalPath", { extend: 'Ext.data.Model', idProperty: 'value', fields: [ {name: 'value', type: 'string'}, {name: 'label', type: 'string'} ] }); } return Ext.create('Ext.data.Store', { model: 'Ametys.odf.widget.EducationalPath', proxy: { type: 'ametys', methodName: 'getEducationalPathsEnumeration', methodArguments: ['programItemId'], role: 'org.ametys.odf.ODFHelper', reader: { type: 'json' } }, sorters: [{property: 'label', direction:'ASC'}], listeners: { beforeload: {fn: this._onStoreBeforeLoad, scope: this} } }); } {code} |
New:
In a AbstractQueryableComboBox widget, idProperty of the combobox store have to be equals to {{valueField}} property. Otherwise #setValue does not work.
Indeed, in #setValue, we use {{me.combobox.getStore().getModel().idProperty}} instead of {{me.valueField}} {code} setValue: function (value) { var me = this; value = Ext.isEmpty(value) ? [] : Ext.Array.from(value); // Values can be either String (of id) or the model var ids = []; Ext.Array.each(value, function(v) { if (Ext.isString(v)) { ids.push(v); } else { ids.push(v[me.combobox.getStore().getModel().idProperty]); me.combobox.getStore().add(v); } }); me.callParent([ids]); me.combobox.setValue(ids); } {code} Model of combobox store and valueField/displayField should be independant. Sample of case, the SelectEducationalPath widget (ODF) does not work with following configuration. It should have. {code} Ext.define('Ametys.odf.widget.SelectEducationalPath', { extend: 'Ametys.form.AbstractQueryableComboBox', valueField: 'id', displayField: 'title', getStore: function() { if (!Ext.data.schema.Schema.get('default').hasEntity('Ametys.odf.widget.EducationalPath')) { Ext.define("Ametys.odf.widget.EducationalPath", { extend: 'Ext.data.Model', idProperty: 'value', fields: [ {name: 'value', type: 'string'}, {name: 'id', type: 'string'}, {name: 'title', type: 'string'} ] }); } return Ext.create('Ext.data.Store', { model: 'Ametys.odf.widget.EducationalPath', proxy: { type: 'ametys', methodName: 'getEducationalPathsEnumeration', methodArguments: ['programItemId'], role: 'org.ametys.odf.ODFHelper', reader: { type: 'json' } }, sorters: [{property: 'title', direction:'ASC'}], listeners: { beforeload: {fn: this._onStoreBeforeLoad, scope: this} } }); } {code} |
Attachment | New: screenshot-1.png [ 29464 ] |