[英]EXTJS 4 : how to get combobox value with out determine combobox id
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);
如何在不使用combobox的確定ID的情況下獲取combobox的值?
Ext.getCmp("ComboBoxType").getValue()
不起作用。
如果您不想使用ID,請改用itemId
。
var val = Ext.ComponentQuery.query('ComboBoxType#yourItemId')[0].getValue();
itemId
的優點是它們不需要唯一。
是的,您應該將'id'
屬性添加到組合框,然后使用'Ext.getCmp('componentId')'
要么
給它分配'name'
屬性,並使用componentquery
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.