Ext.define('MyApp.view.MyVehicleGridPanel', {
extend: 'Ext.grid.Panel',
alias: 'widget.mygrid',
header: false,
store: UserStore,
multiSelect: false,
columns: [
{
xtype: 'gridcolumn',
dataIndex: '_id',
text: 'Vehicle ID'
},
{
xtype: 'gridcolumn',
width: 126,
dataIndex: 'Plat_No',
text: 'Plat Number'
},
{
xtype: 'gridcolumn',
width: 200,
dataIndex: 'Name',
text: 'Added By'
}
]
})
Run Code Online (Sandbox Code Playgroud)
我在gridpanel中没有任何id声明,因为它会动态使用,
所以,我使用别名来查找我的网格组件,如下面的代码
var grid = Ext.ComponentQuery.query('mygrid');
console.log( Ext.ComponentQuery.query('mygrid') );
if (grid.getSelectionModel().hasSelection()) { //error at here
var row = grid.getSelectionModel().getSelection()[0];
console.log(row.get('Plat_No'));
};
Run Code Online (Sandbox Code Playgroud)
但是,firebug返回错误 TypeError: grid.getSelectionModel is not a function
任何其他方式来找到我的网格面板组件?
Ext.ComponentQuery.query()从传递的根对象中返回匹配组件的数组.
因此,如果您mygrid的应用程序中只有一个组件,则可以像这样获取网格:
var grid = Ext.ComponentQuery.query('mygrid')[0];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5194 次 |
| 最近记录: |