在 EXTJS 4 中向 Ext.Grid.panel 添加监听器
我正在尝试向 Ext.grid.panel 添加一个侦听器,
listeners: {
itemclick:function( grid, record, item, index, event){
alert(index);
var record = grid.getStore().getAt(index);
alert("Edit " + record.get('data'));
alert("Type " + record.get('type'));
}
我想获取我单击的行的索引值。因此,当我第一次单击该行时,我在警报框中得到:[object Object],其中包含索引。后两个警报根本不会出现。
所以当我再次单击同一行时。它显示正确的索引,然后显示“数据”,然后在警报框中显示“类型”。
如何仅在第一次点击时获得正确的值?
I am trying to add a listener to a Ext.grid.panel
listeners: {
itemclick:function( grid, record, item, index, event){
alert(index);
var record = grid.getStore().getAt(index);
alert("Edit " + record.get('data'));
alert("Type " + record.get('type'));
}
I suppose to get the index value of the row I clicked. So when I click the row for the first time I get : [object Object] in the alert box with index in it. The second two alerts don't appear at all.
So when I again click the same row. it shows the correct index and then "data" and then " type" in an alert box.
How can I get the right values on the first click only?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我将您的侦听器添加到我自己的网格面板时,我每次都会得到相同的行为。例如:
4/“编辑未定义”/“键入未定义”。
您会看到不同的行为,具体取决于您是否第一次单击某个项目,或者不太可能与网格的创建/渲染方式有关。
作为“索引”传递给侦听器函数的对象的内容可能会给您提供线索。如果您将其记录到控制台,您将能够检查它。 (至少 Chrome 是这样处理对象日志记录的)。
虽然这不能解决您的问题,但我希望它对您的调试有所帮助。
When I add your listener to a grid panel of my own, I get the same behavior every time. For example:
4/"Edit undefined"/"Type undefined".
That you are seeing different behaviors depending on if it is the first time you click an item or not likely has something to do with how the grid is created/rendered.
The content of the Object passed as "index" to your listener function might give you a clue. If you log it to the console you'll be able to inspect it. (At least that's how Chrome handles logging of objects).
While this is not a solution to your problem, I hope it helps in your debugging.