extjs 4网格fireevent itemclick [英] extjs 4 grid fireevent itemclick

查看:81
本文介绍了extjs 4网格fireevent itemclick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

商店加载后如何制作fireEvent itemclick.

How do you make a fireEvent itemclick after the store loads.

我有这个,但是不起作用:

I have this but it doesn't work:

pcfstore.on('load', function(){
   //auto select first row;
   Ext.getCmp('pcf_grid').getSelectionModel().select(0); // this works

   //fire itemclick event
  var grid= Ext.getCmp('pcf_grid');
  grid.fireEvent('itemclick', grid, 0); //this doesnt work

}); 

这是我在网格视图中的itemclick事件:

Here is my itemclick event in grid view:

viewConfig: {
    listeners: {
    itemclick: function(dv, record, item, index, e) {
           alert(record.data.code);
       }
    }
}

基本上,当网格加载时,它应该触发所选第一行的警报窗口 网格.

Basically when the grid loads, it should fire the alert window of the selected first row of the grid.

推荐答案

itemclickView的事件,而不是Grid的事件.尝试使用:

itemclick is event of View but not of Grid. Try to use:

grid.getview().fireEvent('itemclick', grid, 0);

顺便说一句,为什么不使用

And by the way why not use selectionchange instead.

更新

如果同时具有itemcontextmenuselectionchange处理程序,可能会有些混乱.在这种情况下,我建议回到第一方并使用itemclick事件.

If you have both itemcontextmenu and selectionchange handlers it can be a little bit confusing. In this case I recommend back to square one and use itemclick event.

但是您的代码需要进行一些修改:

But your code need to have some modifications:

  1. itemclick事件分配给网格,而不是将其分配给视图.
  2. 触发itemclick时通过实际记录,而不是索引
  1. Assign itemclick event to grid, NOT to it's view.
  2. When firing itemclick pass actual record, NOT an index

像这样:

grid.getSelectionModel().select(0);
grid.fireEvent('itemclick', grid, grid.getSelectionModel().getLastSelected());

这是小提琴,以演示我在说什么.

And here is fiddle to demonstrate what I'm talking about.

这篇关于extjs 4网格fireevent itemclick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆