1. #1
    Sencha User
    Join Date
    Dec 2012
    Location
    hyderabad
    Posts
    91
    Answers
    1
    Vote Rating
    0
    javapurna is on a distinguished road

      0  

    Default Unanswered: mouse right click on grid row display menu

    Unanswered: mouse right click on grid row display menu


    hi every one ,

    i have a requirement to display menu on grid row right click on mouse.

    i am providing screenshot .(like tine20)green-rightclick.jpg

  2. #2
    Sencha User
    Join Date
    Apr 2013
    Posts
    23
    Answers
    4
    Vote Rating
    0
    adanali is on a distinguished road

      0  

    Default add a listener to your grid

    add a listener to your grid


    Code:
    Ext.define('MyApp.view.MyGrid', {
            extend : 'Ext.grid.Panel',
            ...
            listeners : {
                    itemcontextmenu : function(record, item, index, e, eOpts){
                            var xy = eOpts.getXY();
                            Ext.widget('yourDefinedMenu').showAt(xy)
                    },
            },
            ...
    });

  3. #3
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,127
    Answers
    347
    Vote Rating
    516
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    The above answer isn't optimal because it means creating a new menu instance every time. You should cache the menu and only create it if it doesn't exist.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  4. #4
    Sencha User
    Join Date
    Apr 2013
    Posts
    23
    Answers
    4
    Vote Rating
    0
    adanali is on a distinguished road

      0  

    Default


    Quote Originally Posted by evant View Post
    The above answer isn't optimal because it means creating a new menu instance every time. You should cache the menu and only create it if it doesn't exist.
    You can change it easily;


    Code:
    Ext.define('MyApp.view.MyGrid', { 
         extend : 'Ext.grid.Panel',
                ... 
                            listeners : { 
                                        itemcontextmenu : function(record, item, index, e, eOpts){ 
                                                    var xy = eOpts.getXY();                         
                                                    new Ext.menu.Menu({
                                                                items : [{
                                                                            text : 'Add'
                                                                }, {
                                                                            text : 'Add'
                                                                }]
                                                    }).showAt(xy) 
                            }, 
                }, 
                 ... 
    });

  5. #5
    Sencha User
    Join Date
    Dec 2012
    Location
    hyderabad
    Posts
    91
    Answers
    1
    Vote Rating
    0
    javapurna is on a distinguished road

      0  

    Default


    thank you for replaying every one.
    one more is how to get current record (row ) on click of Add button.
    can i use Listener to get store or record .
    if suppose context menu having tow items 1) UPDATE
    2) DELETE IF i am click on update get current row (record id or record)

  6. #6
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,127
    Answers
    347
    Vote Rating
    516
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    @adanali

    That's still exactly the same thing.

    Code:
    Ext.define('Foo', {
        extend: 'Ext.grid.Panel',
        
        initComponent: function(){
            this.callParent();
            this.on('itemcontextmenu', this.showMenu, this);
        },
        
        showMenu: function(record, item, index, e) {
            if (!this.menu) {
                this.menu = new Ext.menu.Menu();
            }
            this.menu.showAt(e.getXY());
        },
        
        onDestroy: function(){
            Ext.destroy(this.menu);
            this.callParent();
        }
    });
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  7. #7
    Sencha User
    Join Date
    Dec 2012
    Location
    hyderabad
    Posts
    91
    Answers
    1
    Vote Rating
    0
    javapurna is on a distinguished road

      0  

    Default


    thanks for replaying evant.

    it is working fine . but it is also display browser menu and behind that display contextmenu.
    i am providing screenshot . contextmenu.jpg







    behind the browser menu contextmenu displaying .how to stop this menu

  8. #8
    Sencha User
    Join Date
    Apr 2013
    Posts
    23
    Answers
    4
    Vote Rating
    0
    adanali is on a distinguished road

      0  

    Default


    I fixed that problem like that:

    In my index.html file

    Code:
    <html>
        <head>
        ...
        </head>
        <body oncontextmenu="return false;"></body>
    </html>

  9. #9
    Sencha User
    Join Date
    Apr 2013
    Posts
    23
    Answers
    4
    Vote Rating
    0
    adanali is on a distinguished road

      0  

    Default


    Quote Originally Posted by evant View Post
    @adanali

    That's still exactly the same thing.

    Code:
    Ext.define('Foo', {
        extend: 'Ext.grid.Panel',
        
        initComponent: function(){
            this.callParent();
            this.on('itemcontextmenu', this.showMenu, this);
        },
        
        showMenu: function(record, item, index, e) {
            if (!this.menu) {
                this.menu = new Ext.menu.Menu();
            }
            this.menu.showAt(e.getXY());
        },
        
        onDestroy: function(){
            Ext.destroy(this.menu);
            this.callParent();
        }
    });
    i accept i am new but what is difference your code from mine?

  10. #10
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,127
    Answers
    347
    Vote Rating
    516
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    As I said above, your code creates a new menu instance every time you right click. Click 10 times, you create 10 menus (DOM included). You don't need to and it will leak memory.

    @javapurna

    http://docs.sencha.com/extjs/4.2.1/#...thod-stopEvent
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

Thread Participants: 2

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar