load the store later, move non-dynamic properties and methods to class body

this fixes two problems:
 * we were loading the store before the parent ComboGrid class could put
  a listener on the load event
  * displayField must now be set in class body, take opportunity to move out
  what we can of the mega initComponent()

this two fixes allow the HA GroupEdit  Window to properly display the
existing members of a HA Group when editing group membership
This commit is contained in:
Emmanuel Kasper 2016-02-25 13:20:07 +01:00 committed by Dietmar Maurer
parent 55bc792342
commit 9ccd656a61

View File

@ -10,12 +10,10 @@ Ext.define('PVE.form.NodeSelector', {
// only allow those nodes (array)
allowedNodes: undefined,
initComponent: function() {
var me = this;
var store = Ext.create('Ext.data.Store', {
valueField: 'node',
displayField: 'node',
store: {
fields: [ 'node', 'cpu', 'maxcpu', 'mem', 'maxmem', 'uptime' ],
autoLoad: true,
proxy: {
type: 'pve',
url: '/api2/json/nodes'
@ -30,12 +28,8 @@ Ext.define('PVE.form.NodeSelector', {
direction: 'DESC'
}
]
});
},
Ext.apply(me, {
store: store,
valueField: 'node',
displayField: 'node',
listConfig: {
columns: [
{
@ -59,10 +53,12 @@ Ext.define('PVE.form.NodeSelector', {
width: 100,
dataIndex: 'cpu'
}
]
],
},
validator: function(value) {
/*jslint confusion: true */
var me = this;
if (!me.onlineValidator || (me.allowBlank && !value)) {
return true;
}
@ -87,13 +83,16 @@ Ext.define('PVE.form.NodeSelector', {
return "Node " + offline.join(', ') + " seems to be offline!";
}
return true;
}
});
},
initComponent: function() {
var me = this;
if (me.selectCurNode && PVE.curSelectedNode.data.node) {
me.preferredValue = PVE.curSelectedNode.data.node;
}
me.callParent();
me.getStore().load();
}
});