1. #1
    Ext User
    Join Date
    Jul 2008
    Posts
    60
    Vote Rating
    0
    villemustonen is on a distinguished road

      0  

    Default Grid SelectionListener

    Grid SelectionListener


    For some reason selecting Grid rows isn't firing Select events.

    Code:
    resultGrid.addListener(Events.Select, controller.getTableListener());
    
    ...
    		
    public SelectionListener<ComponentEvent> getTableListener() {
    	return new SelectionListener<ComponentEvent>() {			
    		public void componentSelected(ComponentEvent ce) {	
    			Window.alert("Test");					
    		}
    	};
    }
    When I click on a grid row, I don't get the alert. What is the proper way to handle selections on a grid, or is this a bug?

  2. #2
    Ext User
    Join Date
    Jul 2008
    Posts
    60
    Vote Rating
    0
    villemustonen is on a distinguished road

      0  

    Default


    This seems to work, but since my the listener calls an RPC-method and I want to minimize RPC-calls, I don't want to do it like this because it gets called even after clicking on a blank spot in the grid.
    Code:
    resultGrid.addListener(Events.OnClick, controller.getTableListener());		
    ---
    public Listener<BaseEvent> getTableListener() {
    	return new Listener<BaseEvent>(){
    		public void handleEvent(BaseEvent be) {
    			method = ATTRIBUTES;
    			MediaObject mediaObject = ((MediaObjectModel) searchWindow
    					.getSearchResults().getSelectedItem())
    					.getMediaObject();
    			searchModel.setSelectedMediaObject(mediaObject);
    			fillMediaObject(mediaObject);				
    	        }
    			
    	};
    }

  3. #3
    Sencha User
    Join Date
    Sep 2010
    Location
    London
    Posts
    6
    Vote Rating
    0
    niyioyelade is on a distinguished road

      0  

    Default


    I am sure you figured this out. However if anyone else is having the problem, a gxt grid has a selection model on to which you can add a listener. This should take care of both cell/row clicks and keyboard navigation on the grid. resultGrid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent se) { //do your stuff here } });

Thread Participants: 1