From cee050e2a15f588d83c7a3d22fc73a7e46d62afa Mon Sep 17 00:00:00 2001 From: Emmanuel Kasper Date: Thu, 4 Feb 2016 17:01:28 +0100 Subject: [PATCH] ext6migrate: fix minor selection bug in the ComboGrid up to now we were only updating the picker selection when the picker was created, which means that subsequent changes in the text field were not propagated to the drop-down list This patch creates a private syncSelection() method which is called each time the picker is shown This is roughly based on the ExtJS 4 ComboBox behaviour --- www/manager6/form/ComboGrid.js | 37 ++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/www/manager6/form/ComboGrid.js b/www/manager6/form/ComboGrid.js index dedf2595..3088e95c 100644 --- a/www/manager6/form/ComboGrid.js +++ b/www/manager6/form/ComboGrid.js @@ -27,6 +27,20 @@ Ext.define('PVE.form.ComboGrid', { displayField: false, valueField: false, matchFieldWidth: false, + // if we have value(s) in the textField, mark them as selected in the picker + // private + syncSelection: function() { + var me = this, previousItems = []; + + if (me.getRawValue()) { + Ext.Array.each(me.getRawValue().split(','), function(record) { + var previousItem = me.store.findRecord(me.valueField, record); + // select only what can be found in the ComboGrid store + previousItem != null && previousItems.push(previousItem); + }); + me.picker.getSelectionModel().select(previousItems); + } + }, createPicker: function() { var me = this; @@ -44,28 +58,21 @@ Ext.define('PVE.form.ComboGrid', { me.fireEvent('select', me, selectedRecords); }, scope: me + }, + show: { + fn: function() { + me.syncSelection(); + }, + scope: me } } }, me.defaultPickerConfig); Ext.apply(config, me.listConfig); - var grid = Ext.create('Ext.grid.Panel', config); + var picker = me.picker = Ext.create('Ext.grid.Panel', config); - // if we have value(s) in the textField, mark them as selected in the picker - if (me.getRawValue()){ - var previousItems = []; - Ext.Array.each(me.getRawValue().split(','), function(record) { - var previousItem = me.store.findRecord(me.valueField, record); - // select only what can be found in the ComboGrid store - previousItem != null && previousItems.push(previousItem); - }); - - grid.getSelectionModel().select(previousItems); - - } - - return grid; + return picker; }, setRecords: function(records) {