Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/461.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript EXT JS 4.2.4-选择网格行[0]->FireEvent('单击'_Javascript_Extjs - Fatal编程技术网

Javascript EXT JS 4.2.4-选择网格行[0]->FireEvent('单击'

Javascript EXT JS 4.2.4-选择网格行[0]->FireEvent('单击',javascript,extjs,Javascript,Extjs,我目前正在处理一个消息框,当您单击网格中显示的消息列表时,该消息将显示在面板中 这方面是可行的,但是当网格第一次加载时,我想自动将网格中的第一项加载到面板中 我的想法是从网格中选择第一个项目,并在其上触发“单击”事件 到目前为止,我还没有找到从网格中选择第一项的方法 我正在使用ExtJS4.2.4 在我的控制器中,我有以下功能: init: function(){ this.control({ afterrender: this.setupGrid }); }, s

我目前正在处理一个消息框,当您单击网格中显示的消息列表时,该消息将显示在面板中

这方面是可行的,但是当网格第一次加载时,我想自动将网格中的第一项加载到面板中

我的想法是从网格中选择第一个项目,并在其上触发“单击”事件

到目前为止,我还没有找到从网格中选择第一项的方法

我正在使用ExtJS4.2.4

在我的控制器中,我有以下功能:

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);
}