1. #1
    Ext User
    Join Date
    Oct 2007
    Location
    Prague, Czech Republic
    Posts
    16
    Vote Rating
    0
    woid is on a distinguished road

      0  

    Default [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.

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    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.
    Code:
    grid.selModel.on('rowselect', function() {alert('x')});
    The alert only displays once when you select via mouse click or up/down arrow.

  3. #3
    Ext User
    Join Date
    Oct 2007
    Location
    Prague, Czech Republic
    Posts
    16
    Vote Rating
    0
    woid is on a distinguished road

      0  

    Default


    Tim, thanks for pointing me to simplest test case.

    You can reproduce the bug by:
    Code:
    grid.selModel.on('rowselect', function() { 
      var body = document.getElementsByTagName('body')[0];
      body.appendChild(document.createTextNode("rowselect ")); 
    });
    adding before selectFirstRow call.

    And by adding this into grid config:
    Code:
    enableDrag: true
    It is reproducible on all my browsers on Windows Vista (IE7, FF2, Opera9.24 and Safari3.0.3).

  4. #4
    Ext User bolanki's Avatar
    Join Date
    Sep 2007
    Posts
    5
    Vote Rating
    0
    bolanki is on a distinguished road

      0  

    Default 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

  5. #5
    Ext User
    Join Date
    Oct 2007
    Location
    Prague, Czech Republic
    Posts
    16
    Vote Rating
    0
    woid is on a distinguished road

      0  

    Default


    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);
    	}
    });

  6. #6
    Ext User
    Join Date
    Mar 2007
    Posts
    3
    Vote Rating
    0
    demartin is on a distinguished road

      0  

    Default 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.

  7. #7
    Ext JS Premium Member
    Join Date
    Jun 2008
    Posts
    19
    Vote Rating
    1
    7twenty is on a distinguished road

      0  

    Default


    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.

  8. #8
    Touch Premium Member letssurf's Avatar
    Join Date
    Jan 2008
    Location
    Northampton, UK
    Posts
    88
    Vote Rating
    1
    letssurf is on a distinguished road

      0  

    Default


    This is still a problem in ver 2.3.

    Any chance of a fix please.
    James Demspter

    the one constant in life, is change.

  9. #9
    Touch Premium Member letssurf's Avatar
    Join Date
    Jan 2008
    Location
    Northampton, UK
    Posts
    88
    Vote Rating
    1
    letssurf is on a distinguished road

      0  

    Default


    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.

  10. #10
    Ext User
    Join Date
    Dec 2007
    Location
    Ukraine
    Posts
    70
    Vote Rating
    0
    yaroslav is on a distinguished road

      0  

    Default


    I try the same in Ext 3.0 and have the same problem
    Sorry for terrible english. My native language is PHP
    my sites:
    http://restime.net/

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."