Ext.define('MyApp.view.MyPanel21233', {
extend: 'Ext.panel.Panel',
alias: 'widget.dailywindow',
header: false,
width: window.innerWidth,
height: window.innerHeight,
initComponent: function() {
var me = this;
Ext.applyIf(me, {
items: [
{
xtype: 'container',
layout: {
align: 'stretch',
type: 'hbox'
},
items: [
{
xtype: 'gridpanel',
width: 200,
alias: 'widget.mydailychartgrid',
height: window.innerHeight - 100,
header: false,
store : VehicleStore_Chart,
title: 'My Grid Panel',
columns: [
{
xtype: 'gridcolumn',
dataIndex: 'Plat_No',
text: 'Plat No'
}
],
selModel: Ext.create('Ext.selection.CheckboxModel', {
checkOnly : true // for prevent clicked grid row and canceled all check box checked status
})
}//item
,win
]
}
]//item
,
dockedItems: [
{
xtype: 'toolbar',
dock: 'top',
height: 40,
items: [
{
xtype: 'datefield',
fieldLabel: 'Start',
labelWidth: 50,
format: 'Y-m-d',
value: new Date()
},
{
xtype: 'datefield',
fieldLabel: 'End',
labelWidth: 50,
format: 'Y-m-d',
value: new Date()
},
{
xtype: 'button',
text: 'Generate',
iconCls: 'OK',
height: 34,
width: 80,
listeners: {
'click': function(c){
GenerateButtonClick();
}
}
}
]
}
]
});
me.callParent(arguments);
}
});
如何在我的网格面板行中检查Plat_No
?
var record = Ext.ComponentQuery.query('mydailychartgrid')[0].getSelectionModel().getSelection()
for (var j = 0; j < record.length; j++){
record.get('Plat_No');
}
什么都不对? TypeError: Ext.ComponentQuery.query(...)[0] is undefined
错误
答案 0 :(得分:1)
请检查以下代码。
Ext.define('MyApp.view.MyPanel21233', {
extend: 'Ext.panel.Panel',
alias: 'widget.dailywindow',
header: false,
width: window.innerWidth,
height: window.innerHeight,
initComponent: function() {
var me = this;
Ext.applyIf(me, {
items: [
{
xtype: 'container',
layout: {
align: 'stretch',
type: 'hbox'
},
items: [
{
xtype: 'gridpanel',
width: 200,
//alias: 'widget.mydailychartgrid',
name:'mydailychartgrid',
height: window.innerHeight - 100,
header: false,
store : VehicleStore_Chart,
title: 'My Grid Panel',
columns: [
{
xtype: 'gridcolumn',
dataIndex: 'Plat_No',
text: 'Plat No'
}
],
selModel: Ext.create('Ext.selection.CheckboxModel', {
checkOnly : true // for prevent clicked grid row and canceled all check box checked status
})
}//item
,win
]
}
]//item
,
dockedItems: [
{
xtype: 'toolbar',
dock: 'top',
height: 40,
items: [
{
xtype: 'datefield',
fieldLabel: 'Start',
labelWidth: 50,
format: 'Y-m-d',
value: new Date()
},
{
xtype: 'datefield',
fieldLabel: 'End',
labelWidth: 50,
format: 'Y-m-d',
value: new Date()
},
{
xtype: 'button',
text: 'Generate',
iconCls: 'OK',
height: 34,
width: 80,
listeners: {
'click': function(c){
GenerateButtonClick();
}
}
}
]
}
]
});
me.callParent(arguments);
}
});
而不是'alise'定义'name'属性,然后通过以下代码。
var record = Ext.ComponentQuery.query('dailywindow gridpanel[name=mydailychartgrid]')[0].getSelectionModel().getSelection();
答案 1 :(得分:0)
正如它所暗示的那样,查询找不到任何东西。创建实例时,无法指定alias
。您需要提供一些其他方法来查找组件(可能是itemId
)。