Ext.ns('ES');

ES.EnergyCombobox= Ext.extend(Ext.form.ComboBox,{
  xtype: 'combo',
  id: 'combo1Id',
  name: 'energy_type',
  fieldLabel: 'energie',
  mode: 'local',
  displayField: 'name',
  valueField: 'uid',
  triggerAction: 'all',
  lazyRender:true,
  store:new Ext.data.Store({
    autoLoad:true,
    proxy: new Ext.data.HttpProxy({
      url:'/process/extjs/site/consumption/heating/heatingcounter.php'
    }),
    baseParams:{cmd: "energy"},
    reader: new Ext.data.JsonReader({
      fields: ['uid','name'],
      root: 'data'

    })
  }),
  listeners: {
    select:{
      fn:function(combo, value){
        var unitCombo= Ext.getCmp('combo2Id');
        unitCombo.refresh();
      }
    }
  }
  ,initComponent: function() {
    var config = {};
    Ext.apply(this, Ext.apply(this.initialConfig, config));
    ES.EnergyCombobox.superclass.initComponent.apply(this, arguments);
  }
  ,onRender:function() {
    ES.EnergyCombobox.superclass.onRender.apply(this, arguments);
    //var energyCombo= Ext.getCmp('combo1Id');
    //energyCombo.setValue('gaz');
  }
});

Ext.reg('ESenergyCombobox', ES.EnergyCombobox);

