[pve-devel] [PATCH pve-manager] ext6migrate: fix minor selection bug in the ComboGrid

Emmanuel Kasper e.kasper at proxmox.com
Thu Feb 4 17:01:28 CET 2016


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 dedf259..3088e95 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);
-
-        // 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);
-
-        }
+        var picker = me.picker = Ext.create('Ext.grid.Panel', config);
 
-        return grid;
+        return picker;
     },
 
     setRecords: function(records) {
-- 
2.1.4





More information about the pve-devel mailing list