Ext.ns('ES');

ES.UnitCombobox= Ext.extend(Ext.form.ComboBox,{
  xtype: 'combo',
  id: 'combo2Id',
  name: 'unit',
  fieldLabel: 'unité',
  mode: 'local',
  displayField: 'name',
  triggerAction: 'all',
  valueField: 'unitId',
  editable:false,
  lazyRender:true
  ,initComponent: function() {
    var config = {
      items:[{}]
      ,store: new Ext.data.Store({
        autoLoad:false,
        ownerCt:this
        ,proxy: new Ext.data.HttpProxy({
          url:'/process/extjs/site/consumption/heating/heatingcounter.php'
        }),
        reader: new Ext.data.JsonReader({
        fields: ['unitId', 'name'],
        root: 'data'
        })
      })
    };
    Ext.apply(this, Ext.apply(this.initialConfig, config));
    ES.UnitCombobox.superclass.initComponent.apply(this, arguments);
  }
  ,onRender:function() {
    ES.UnitCombobox.superclass.onRender.apply(this, arguments);
    var energy_selected= Ext.getCmp('combo1Id').getValue();
  }
  ,refresh:function() {
    var energy_selected= Ext.getCmp('combo1Id').getValue();
    this.store.load({
      url:this.url
      ,waitMsg:'Loading...'
      ,params:{cmd:'unit',energy_value:energy_selected}
    });
  }
});

Ext.reg('ESunitCombobox', ES.UnitCombobox);


