-
21 Nov 2007 6:59 AM #1
[FIXED][2.x] Ext.grid.RowSelectionModel.selectRow called twice when click on row
[FIXED][2.x] Ext.grid.RowSelectionModel.selectRow called twice when click on row
I have GridPanel with enableDragDrop and Ext.grid.RowSelectionModel.
I want to store selection server-side. I need to override Ext.grid.RowSelectionModel.selectRow to do some AJAX about selection change.
Problem:
My grid calls selectRow twice on single click into row on FF, Opera and Safari. On IE it is called only once.
Solution:
Ext.grid.RowSelectionModel.initEvents defines rowclick event handler. This causes redundant second call to selectRow. The first call to selectRow was previously done in Ext.grid.RowSelectionModel.handleMouseDown (and I hope this is right place where to handle selections).
Maybe this rowclick event is there for some good reason, but in my case it causes troubles and I don't want to clutter my code with detections of redundant selectRow calls. I've just commented it out.
-
21 Nov 2007 7:39 AM #2
Please read this before posting a bug http://extjs.com/forum/showthread.php?t=13985.
This is likely a bug in your code, the selectRow fn is not called twice. You can verify this by adding the following line to the array grid example before the selectFirstRow() call.
The alert only displays once when you select via mouse click or up/down arrow.Code:grid.selModel.on('rowselect', function() {alert('x')});Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
21 Nov 2007 11:26 AM #3
Tim, thanks for pointing me to simplest test case.
You can reproduce the bug by:
adding before selectFirstRow call.Code:grid.selModel.on('rowselect', function() { var body = document.getElementsByTagName('body')[0]; body.appendChild(document.createTextNode("rowselect ")); });
And by adding this into grid config:
It is reproducible on all my browsers on Windows Vista (IE7, FF2, Opera9.24 and Safari3.0.3).Code:enableDrag: true
-
22 Nov 2007 5:11 AM #4
Same problem
Same problem
If a grid is drag and drop enabled, the following 3 functions get called twice:
beforerowselect
rowselect
selectionchange
The reason for this is that the internal DragSource component that gets added to the Grid, calls the selectRow function on the RowSelectionModel component via its handleMouseDown event. The selectRow function gets called again from within the RowSelectionModel
-
22 Nov 2007 12:57 PM #5
This works for me, I use modified RowSelectionModel:
1. commented out rowclick event handler
2. sanitized "up" to do nothing when lastActive is 0 (active carret is on the first row and there is no room to move up)
3. sanitize "down" to do nothing when lastActive is on last grid row
Changes 2 and 3 are probably not important for you, because selectRow handles this situation and does nothing. I just needed to have clean calls to selectRange for my server notifications.
Code:FixedRowSelectionModel = function(config) { FixedRowSelectionModel.superclass.constructor.call(this, config); }; Ext.extend(FixedRowSelectionModel, Ext.grid.RowSelectionModel, { //---------------------------------------------------------------------------------------- initEvents : function(){ if(!this.grid.enableDragDrop && !this.grid.enableDrag){ this.grid.on("rowmousedown", this.handleMouseDown, this); }else{ /* this.grid.on("rowclick", function(grid, rowIndex, e) { if(e.button === 0 && !e.shiftKey && !e.ctrlKey) { this.selectRow(rowIndex, false); grid.view.focusRow(rowIndex); } }, this); */ } this.rowNav = new Ext.KeyNav(this.grid.getGridEl(), { "up" : function(e){ if(!e.shiftKey){ this.selectPrevious(e.shiftKey); }else if(this.last !== false && this.lastActive !== false){ if (this.lastActive>0) { var last = this.last; this.selectRange(this.last, this.lastActive-1); this.grid.getView().focusRow(this.lastActive); if(last !== false){ this.last = last; } } }else{ this.selectFirstRow(); } }, "down" : function(e){ if(!e.shiftKey){ this.selectNext(e.shiftKey); }else if(this.last !== false && this.lastActive !== false){ if (this.lastActive<this.grid.store.getCount()-1) { var last = this.last; this.selectRange(this.last, this.lastActive+1); this.grid.getView().focusRow(this.lastActive); if(last !== false){ this.last = last; } } }else{ this.selectFirstRow(); } }, scope: this }); var view = this.grid.view; view.on("refresh", this.onRefresh, this); view.on("rowupdated", this.onRowUpdated, this); view.on("rowremoved", this.onRemove, this); } });
-
7 Mar 2008 4:23 AM #6
Not fixed on 2.0.2
Not fixed on 2.0.2
I found the same problem on 2.0.2 when you set enableDragDrop on grid.
It fires the rowselect event twice.
-
11 Nov 2008 2:44 PM #7
I also experience this same problem on 2.0.2 when enableDragDrop is set on a grid.
It fires the beforerowselect event twice.ExtJS is amazing.
-
20 Aug 2009 11:34 AM #8
This is still a problem in ver 2.3.
Any chance of a fix please.James Demspter
the one constant in life, is change.
-
21 Aug 2009 1:34 AM #9
Sorry my mistake, I see it has been fixed in 2.3
I was enabling enableDragDrop after initEvents.
James Demspter
the one constant in life, is change.
-
5 Oct 2009 1:00 AM #10
I try the same in Ext 3.0 and have the same problem



Reply With Quote

