Javascript EXT JS 4.2.4-选择网格行[0]->FireEvent('单击'
我目前正在处理一个消息框,当您单击网格中显示的消息列表时,该消息将显示在面板中 这方面是可行的,但是当网格第一次加载时,我想自动将网格中的第一项加载到面板中 我的想法是从网格中选择第一个项目,并在其上触发“单击”事件 到目前为止,我还没有找到从网格中选择第一项的方法 我正在使用ExtJS4.2.4 在我的控制器中,我有以下功能:Javascript EXT JS 4.2.4-选择网格行[0]->FireEvent('单击',javascript,extjs,Javascript,Extjs,我目前正在处理一个消息框,当您单击网格中显示的消息列表时,该消息将显示在面板中 这方面是可行的,但是当网格第一次加载时,我想自动将网格中的第一项加载到面板中 我的想法是从网格中选择第一个项目,并在其上触发“单击”事件 到目前为止,我还没有找到从网格中选择第一项的方法 我正在使用ExtJS4.2.4 在我的控制器中,我有以下功能: init: function(){ this.control({ afterrender: this.setupGrid }); }, s
init: function(){
this.control({
afterrender: this.setupGrid
});
},
setupGrid: function(grid)
{
grid.getStore().load();
//console.log(grid.getSelectionModel().select(0)); // Uncaught TypeError: Cannot read property 'id' of undefined.
//console.log(this.grid.getSelectionModel().selectFirstRow()); // Uncaught TypeError: Cannot read property 'getSelectionModel' of undefined
}
我尝试过,Columns会给我列标题,我尝试过“Child”和我在stacks上找到的几种方法,但似乎仍然无法实现。非常感谢任何帮助:您可以等待存储加载,然后选择第一条记录:
setupGrid: function(grid) {
grid.store.on('load', function(store){
grid.getSelectionModel().select(store.first());
}, this);
}
您可以等待存储加载,然后选择第一条记录:
setupGrid: function(grid) {
grid.store.on('load', function(store){
grid.getSelectionModel().select(store.first());
}, this);
}