ExtJs / Sencha:如何在插入后突出显示网格行?
我想创建这样一个网格: http://www.sencha.com/deploy/dev/ example/grid/edit-grid.html
实际上我已经这样做了,但我想突出显示网格中最后插入的行(在 extjs 中,这是函数highlight(),它会对元素进行淡黄处理)。
我实际上并没有成功地做到这一点...我的问题是我无法获得刚刚插入的行,因此显然我无法突出显示它。 有什么线索吗?
提前致谢
I want to create such a grid:
http://www.sencha.com/deploy/dev/examples/grid/edit-grid.html
Actually I already did, but I want to highlight the last inserted row of my grid (in extjs this is the function highlight(), which does a yellowfade on the element).
I didn't actually succeed in doing this... my problem is that I can't get the row I just inserted, and thus obviously I can't highlight it.
Any clues?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您只需要执行此操作(此处为第一行):
就这么简单。
You only need to do this (here for row number one):
It's that easy.
代码有
那么您不直接在该语句之后突出显示第 0 行吗?
The code has
So don't you just highlight row zero immediately after that statement?
是的,抱歉回答太晚了,
使用 Ext.grid.RowSelectionModel 而不是使用 selectLastRow 函数,您可以轻松地指出它:)
yes sorry for answering too late,
use Ext.grid.RowSelectionModel and than use selectLastRow function u can easily will be able to point it out :)
Ext.data.store 有一个添加侦听器,向其传递插入记录的索引
add : ( Store this, Ext.data.Record[] reports, Number index )
Ext.data.store has a add listener which is passed an index at which records were inserted
add : ( Store this, Ext.data.Record[] records, Number index )
这将进入您的添加/创建按钮事件内部。代码
this.getSelectionModel().select(0);
将突出显示自我们插入位置 0 以来的第一行,我们正在选择位置 0。此代码适用于 ExtJS 4.2.0。This would go inside of your add/create button event. The code
this.getSelectionModel().select(0);
will highlight the first row since we inserted into position 0, we are selecting position 0. This code works with ExtJS 4.2.0.