1. #1
    Sencha User
    Join Date
    Jan 2009
    Location
    PARIS
    Posts
    8
    Vote Rating
    0
    Gildas is on a distinguished road

      0  

    Default Context menu not show after upgrade gxt 2.11 -> gxt 2.1.2

    Context menu not show after upgrade gxt 2.11 -> gxt 2.1.2


    Hi.

    I change dynamically the context menu in function of the row's properties of the grid.


    // treeGrid
    treeGrid = new TreeGrid<PolePatrimonialData>(store, cm){

    // Gestion du menu contextuel
    @Override
    protected void onRightClick(ComponentEvent ce) {

    PolePatrimonialData data = this.getSelectionModel().getSelectedItem();

    if (data!=null && !(data instanceof PolePatrimonialParentTreeData)) {
    if ("C".equals(data.getNature())){
    this.setContextMenu(contextMenuClient);
    }else if ("P".equals(data.getNature())){
    this.setContextMenu(contextMenuProspect);
    }else if ("R".equals(data.getNature())){
    this.setContextMenu(contextMenuReseau);
    }
    }else{
    this.setContextMenu(contextMenuRo);
    }
    super.onRightClick(ce);
    }
    };


    gxt 2.1.1 works fine
    gxt 2.1.2 not works

    This is a very blocking problem for our applications.

    Gildas

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,715
    Vote Rating
    107
    sven is just really nice sven is just really nice sven is just really nice sven is just really nice

      0  

    Default


    Can you please post a working testcase for this? This testcase should implement EntryPoint

  3. #3
    Sencha User
    Join Date
    Jan 2009
    Location
    PARIS
    Posts
    8
    Vote Rating
    0
    Gildas is on a distinguished road

      0  

    Default


    Exemple :
    gxt 2.1.1 works fine
    gxt 2.1.2 not works
    (IE like FF)


    Code:
    import java.util.Arrays;
    
    import com.extjs.gxt.ui.client.data.BaseModelData;
    import com.extjs.gxt.ui.client.event.ComponentEvent;
    import com.extjs.gxt.ui.client.store.ListStore;
    import com.extjs.gxt.ui.client.widget.ContentPanel;
    import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
    import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
    import com.extjs.gxt.ui.client.widget.grid.Grid;
    import com.extjs.gxt.ui.client.widget.layout.FitLayout;
    import com.extjs.gxt.ui.client.widget.menu.Menu;
    import com.extjs.gxt.ui.client.widget.menu.MenuItem;
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.ui.RootPanel;
    
    /**
     * Entry point classes define <code>onModuleLoad()</code>.
     */
    public class PbContextMenu implements EntryPoint {
        
        
        public class MyData extends BaseModelData {
            
            public MyData() {
            }
    
            public MyData(String nature) {
                set("nature", nature);
            }
            
            public String getNature() {
                return (String) get("nature");
            }
            
            public void setNature(String nature) {
                set("nature", nature);
            }
        }
        
        private Menu contextMenuClient;
        private Menu contextMenuProspect;
        private Menu contextMenuReseau;
        private Menu contextMenuRo;
        
        /**
         * This is the entry point method.
         */
        public void onModuleLoad() {
            
            contextMenuClient = createMenuContextuel("C");
            contextMenuProspect = createMenuContextuel("P");
            contextMenuReseau = createMenuContextuel("R");
            contextMenuRo = createMenuContextuel("Other");
            
            
            ColumnConfig nat = new ColumnConfig("nature", "nature", 100);
            ColumnModel cm = new ColumnModel(Arrays.asList(nat));
            
            ListStore<MyData> store = new ListStore<MyData>();
            store.add(new MyData("C"));
            store.add(new MyData("P"));
            store.add(new MyData("R"));
            
            Grid<MyData> grid = new Grid<MyData>(store, cm){ 
                
                @Override
                protected void onRightClick(ComponentEvent ce) {    
                    
                    MyData data = this.getSelectionModel().getSelectedItem();
                    
                    if (data!=null) {
                        if ("C".equals(data.getNature())){
                            this.setContextMenu(contextMenuClient);
                        }else if ("P".equals(data.getNature())){
                            this.setContextMenu(contextMenuProspect);
                        }else if ("R".equals(data.getNature())){
                            this.setContextMenu(contextMenuReseau);
                        }
                    }else{
                        this.setContextMenu(contextMenuRo);
                    }
                    super.onRightClick(ce);
                  }
            };
            
            
            
            ContentPanel lay = new ContentPanel(new FitLayout());
            lay.setSize(300, 200);
            lay.add(grid);
            
            RootPanel.get().add(lay);
        }
        
        private Menu createMenuContextuel(String s){
            Menu contextMenu = new Menu();
            contextMenu.setWidth(140);
            
            MenuItem crm = new MenuItem();
            crm.setText(s);
            contextMenu.add(crm);
            
            return contextMenu;
        }
    }

  4. #4
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,715
    Vote Rating
    107
    sven is just really nice sven is just really nice sven is just really nice sven is just really nice

      0  

    Default


    There is no contextmenu set in the first place. Thats why onRightClick enver gets called.

    add this line:
    Code:
      grid.sinkEvents(Event.ONCONTEXTMENU);

  5. #5
    Sencha User
    Join Date
    Jan 2009
    Location
    PARIS
    Posts
    8
    Vote Rating
    0
    Gildas is on a distinguished road

      0  

    Default


    Yes. It works great now. Thanks