更新时间:2023-11-26 10:14:52
itemclick
是View
的事件,而不是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.
更新
如果同时具有itemcontextmenu
和selectionchange
处理程序,可能会有些混乱.在这种情况下,我建议回到第一方并使用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:
itemclick
事件分配给网格,而不是将其分配给视图.itemclick
时通过实际记录,而不是索引itemclick
event to grid, NOT to it's view.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.