ExtJS4:如何在不确定组合框id的情况下获取组合框值

ExtJS4:如何在不确定组合框id的情况下获取组合框值,extjs,Extjs,如何在不使用combobox中的determine id的情况下获取combobox值? Ext.getCmp(“ComboBoxType”).getValue()不起作用。是的,您应该向combobox添加'id'属性,然后使用'Ext.getCmp('componentId') 或 将'name'属性分配给它,并使用组件查询如果不想使用id,请改用 itemId的优点是它们不需要是唯一的。您应该在组合框定义中提供一个id,比如id:'myCombo',然后您可以与getCmp一起使用! va

如何在不使用combobox中的determine id的情况下获取combobox值?

Ext.getCmp(“ComboBoxType”).getValue()
不起作用。

是的,您应该向combobox添加
'id'
属性,然后使用
'Ext.getCmp('componentId')


'name'
属性分配给它,并使用
组件查询

如果不想使用id,请改用


itemId
的优点是它们不需要是唯一的。

您应该在组合框定义中提供一个id,比如
id:'myCombo'
,然后您可以与getCmp一起使用!
var StaticComboBox = Ext.define('MyApp.view.ComboBoxType', {
  extend: 'Ext.form.ComboBox',
  mode: 'local',
  fieldLabel: 'Type',
  labelWidth: 50,
  triggerAction: 'all',
  editable: false,
  valueField: 'value',
  displayField: 'label', 
  data: [
               {value: 0, label: 'By Vehicle'},  {value: 1, label: 'By Route'}
          ] ,
  initComponent: function() {
    this.store = new Ext.data.Store({
      fields: ['value', 'label'],
      data: this.data
    });
    StaticComboBox.superclass.initComponent.call(this);
  },
  listeners: {
        change: function (combo, value) {
        var grid = Ext.ComponentQuery.query('dailywindow gridpanel[name=mydailychartgrid]')[0];
        if (grid != null){
            if (value == 0) {
            //grid.reconfigure(VehicleStore_Chart,VehicleModel)
            grid.reconfigure(VehicleStore_Chart);
            grid.columns[1].setText('Plat No');
            grid.columns[1].dataIndex = "Plat_No"
            grid.columns[1].width = 100
            }else{

            //grid.reconfigure(RouteNameStore_DailyChart,RouteModel)
            grid.reconfigure(RouteNameStore_DailyChart)
            grid.columns[1].setText('Route Code');
            grid.columns[1].dataIndex = "Route_Code"
            grid.columns[1].width = 100
            }
        }
        //alert(value);
        }
  }

});

var c = new StaticComboBox();
c.setValue(0);
var val = Ext.ComponentQuery.query('ComboBoxType#yourItemId')[0].getValue();