网格行上的 Ext GWT (GXT) 工具提示
我正在为我的一个项目使用 Ext GWT (GXT) 开发一个自定义工具提示,并且当选择网格行时,此工具提示必须显示在网格行上。 我无法使用默认的 GXT 工具提示或快速提示,因为我需要能够向此工具提示添加组件(如按钮)。
问题是 GXT Grid 组件没有公开与鼠标悬停在行上相关的事件(尽管有 RowClick 和 RowMouseDown)。 无论如何,我尝试使用 OnMouseOver 和 OnMouseOut 事件向网格添加侦听器,但它无法按预期工作。每当它触发这些事件 将鼠标悬停在组成一行的任何 div 和 span 上。
我认为解决这个问题的唯一方法是子类化 GridView 组件并使每一行本身成为一个组件, 但这会是一项繁重的工作,并且可能还会影响性能。我忍不住想有更好的方法来做到这一点。
有 GXT 经验丰富的人可以给我指点迷津吗?
I'm developing a custom tooltip using Ext GWT (GXT) for a project of mine, and this tooltip has to appear over Grid rows when they're selected.
I can't use the default GXT tooltip or quicktip because I need be able to add Components (like buttons) to this tooltip.
The problem is that the GXT Grid component doesn't expose a event related to mousing over a row (although there's RowClick and RowMouseDown).
I tried adding a listener to the Grid with the OnMouseOver and OnMouseOut events anyway, but it doesn't work as expected. It fires these events up whenever
you mouse over any of the divs and spans that composes a row.
The only way I see to solve this is to subclass the GridView component and make each row become a Component itself,
but that would be a lot of work and would probably impact performance as well. I can't help but think there's a better way to do this.
Could someone more experienced with GXT give me a light?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
试试这个
try this
onComponentEvent()(在 com.extjs.gxt.ui.client.widget.Component 中定义,主体为空,并在 com.extjs.gxt.ui.client.widget.grid.Grid 中覆盖)也接收类型为 Event.ONMOUSEOVER 的事件和 Event.ONMOUSEOUT
Grid 类中的默认实现不处理这些事件,因此您可能希望在子类中重写此函数。
另外,在onComponentEvent()结束时,Grid调用GridView的handleComponentEvent()函数。
onComponentEvent() (defined in com.extjs.gxt.ui.client.widget.Component with an empty body and overridden in com.extjs.gxt.ui.client.widget.grid.Grid) also receives Events with type Event.ONMOUSEOVER and Event.ONMOUSEOUT
The default implementation in the Grid class doesn't handle those events, so you may want to override this function in a subclass.
Additionally, at the end of onComponentEvent(), the Grid calls the function handleComponentEvent() of the GridView.
我发现有两种方法可以做到这一点:
1.对于网格的特定列描述渲染器,例如:
和您的渲染器功能:
但只有当您的鼠标指针位于该特定列上方时,此方法才有效。
2.对于网格的“渲染”事件应用/使用此功能:
我希望这对您有帮助:)
I found 2 ways to do that:
1.For specific column of the grid describe renderer, e.g.:
And your renderer function:
But this method will work only when your mouse pointer will be above that specific column.
2.For 'render' event of the grid apply/use this function:
I hope this will be helpful to you :)
我知道这已经过时了,但没有公认的答案,我想我找到了更好的方法:
I know this is old but there's no accepted answer and I think I found a better way:
我正在使用 GWT 2.6 和 GXT 3.1.0,我设法以这种方式做到这一点......
这里的 RowSet 类类似于 Map
I am using GWT 2.6 and GXT 3.1.0 and I managed to do this in this way ....
Here the class RowSet is analogous to a Map