且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

extjs 4网格fireevent itemclick

更新时间:2023-11-26 10:14:52

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.