1. #1
    Ext User
    Join Date
    Sep 2008
    Posts
    16
    Vote Rating
    0
    sinthamethar is on a distinguished road

      0  

    Default How to i catch doubleclick event on gxt grid?

    How to i catch doubleclick event on gxt grid?


    How do i catch double click event in gxt grid?

    Here is what i am trying to do it. But double click event never fire this code.

    grid.getSelectionModel().addListener(Events.
    DoubleClick, new Listener<GridEvent>() {
    publicvoid handleEvent(GridEvent be) {
    MessageBox.alert(
    "Test", "DoubleClick", null);
    GridSelectionModel sm = be.
    grid.getSelectionModel();
    }

    });

    Events.OnDoubleClick also not working.


  2. #2
    Ext User
    Join Date
    Oct 2008
    Location
    Atlanta ,GA
    Posts
    239
    Vote Rating
    0
    kolli is on a distinguished road

      0  

    Default


    Code:
        grid.addListener(Events.CellDoubleClick, new Listener<BaseEvent>(){
                public void handleEvent(BaseEvent be) {
                    GridEvent ge = (GridEvent)be;
                    if(ge.colIndex != 0)
                    {
                      //Do something
                    }
                }
            });

  3. #3
    Ext User
    Join Date
    Aug 2009
    Posts
    19
    Vote Rating
    0
    TOMMYZHANG is on a distinguished road

      0  

    Default


    thank you kolli.
    Can i get the cell value where i click.?

  4. #4
    Sencha User
    Join Date
    Nov 2008
    Location
    Vienna - Austria
    Posts
    867
    Vote Rating
    1
    micgala is on a distinguished road

      0  

    Default


    Yes, you can:

    The gridEvent has the value attribute.
    See if that is the value you are looking for.

    Otherwise, you have also the propertyName, and the model.

    just do model.get(propertyName).
    Also, if still you don't have it there (I guess there was a bug where some things were not getting filled in the gridEvent, not sure if it is fixed already).

    The you can do this

    ModelData model = yourGrid.getStore().get(gridEvent.rowIndex);
    X value = model.get(gridEvent.propertyName)

    Hope this helps you.

    Regards,
    Michel.

  5. #5
    Sencha User borisperezg's Avatar
    Join Date
    May 2010
    Posts
    22
    Vote Rating
    0
    borisperezg is on a distinguished road

      0  

    Default


    Hi, thats work for me... but, I had to put this validation:
    GridEvent ge = (GridEvent)be;
    if(ge==null)
    MessageBox.alert("Grid", "Coming null", null);
    else{
    txtEntidad.setValue(ge.getModel().get("nombre").toString());
    dialogEntidad.hide();
    }

    Anyway... perfect advice.

  6. #6
    Sencha User
    Join Date
    Dec 2008
    Posts
    1
    Vote Rating
    0
    orcart is on a distinguished road

      0  

    Default this could be easier

    this could be easier


    This could be easier, you don't need casting and could be more safe

    grid.addListener(Events.RowDoubleClick, new Listener<GridEvent<BeanModel>>(){


    @Override
    public void handleEvent(GridEvent<BeanModel> be) {

    Window.open("http://google.com", "_blank", null);

    }});

  7. #7
    Sencha User
    Join Date
    Apr 2011
    Posts
    1
    Vote Rating
    0
    khanh_vina is on a distinguished road

      0  

    Default


    Quote Originally Posted by kolli View Post
    Code:
        grid.addListener(Events.CellDoubleClick, new Listener<BaseEvent>(){
                public void handleEvent(BaseEvent be) {
                    GridEvent ge = (GridEvent)be;
                    if(ge.colIndex != 0)
                    {
                      //Do something
                    }
                }
            });
    thanks for your sharing your information.I like it.

  8. #8
    Sencha User
    Join Date
    Aug 2011
    Posts
    5
    Vote Rating
    0
    Francol is on a distinguished road

      0  

    Default


    The "Add event handler" command can be used to create event handlers for any of the standard typed events supported by GWT and GXT.

  9. #9
    Sencha User
    Join Date
    Jul 2009
    Posts
    16
    Vote Rating
    0
    sajjan.sarkar is on a distinguished road

      0  

    Default slight optimization

    slight optimization


    Quote Originally Posted by kolli View Post
    Code:
        grid.addListener(Events.CellDoubleClick, new Listener<BaseEvent>(){
                public void handleEvent(BaseEvent be) {
                    GridEvent ge = (GridEvent)be;
                    if(ge.colIndex != 0)
                    {
                      //Do something
                    }
                }
            });
    Thanks Kolli, you're awesome! Just a small optimization, you can avoid a cast by explicitly using the correct BaseEvent subclass, in this case GridEvent.
    Code:
    grid.addListener(Events.CellDoubleClick, new Listener<GridEvent<Employee>>() {
                
                @Override
                public void handleEvent(GridEvent<Employee> be) {
                    System.out.println(be.getModel().getEmployeeName());
                    
                }
                
            });

  10. #10
    Sencha User
    Join Date
    Jan 2012
    Posts
    5
    Vote Rating
    0
    EstebanJBO is on a distinguished road

      0  

    Default


    Works like a charm. thx a lot.