1. #1
    Sencha User Misiu's Avatar
    Join Date
    Jun 2012
    Location
    Poland
    Posts
    196
    Answers
    6
    Vote Rating
    31
    Misiu has a spectacular aura about Misiu has a spectacular aura about

      0  

    Default Answered: MessageBox pass extra param to handler

    Answered: MessageBox pass extra param to handler


    I've created context menu for a control like so:
    Code:
    onEventContextMenu: function (s, rec, e) {
            e.stopEvent();
    
            if (!s.ctx) {
                s.ctx = new Ext.menu.Menu({
                    items: [{
                        text: 'Delete event',
                        iconCls: 'icon-delete',
                        scope: this,
                        handler : function() {
                        Ext.MessageBox.show({
                                        title : 'Reason',
                                        msg : 'place reason:',
                                        width : 300,
                                        buttons : Ext.MessageBox.OKCANCEL,
                                        multiline : true,
                                        fn : this.showResultText(buttonId, text, rec)//how to pass rec to handler?
                                    });
                        }
                    },{
                                text : 'Accept',
                                iconCls : 'accept',
                                handler : function() {
                                    alert(rec.get('Title'));
                                }
                            }, 
                    ]
                });
            }
            s.ctx.rec = rec;
            s.ctx.showAt(e.getXY());
        },
        
        showResultText : function (btn, text, record){
        alert(btn);
            if (btn == 'cancel') {
                alert(text + ' cancel');
            }
            if (btn == 'ok') {
                alert(record.get('Title'));
            }
        },
    I can access rec in second option. But when user choose first option he gets messageBox to enter some text, after than I would like to access rec from showResultText function.
    How to do that? Add extra parameter? If yes, then how?

  2. I've changed a bit my code:
    Code:
        onEventContextMenu: function (s, rec, e) {
            e.stopEvent();
    
            if (!s.ctx) {
                s.ctx = new Ext.menu.Menu({
                    items: [{
                        text: 'Delete event',
                        iconCls: 'icon-delete',
                        scope: this,
                        handler : function() {
                        Ext.MessageBox.show({
                                        title : 'Reason',
                                        msg : 'place reason:',
                                        width : 300,
                                        buttons : Ext.MessageBox.OKCANCEL,
                                        multiline : true,
                                        scope: this,
                                        fn : function(btn,text){ if (btn == 'ok') this.showResultText(rec);}
                                        //fn : this.showResultText(buttonId, text, rec)
                                    });
                        }
                    },{
                                text : 'Accept',
                                iconCls : 'accept',
                                handler : function() {
                                    alert(rec.getName());
                                }
                            }, 
                    ]
                });
            }
            s.ctx.rec = rec;
            s.ctx.showAt(e.getXY());
        },
        
        showResultText : function (record, reason){
                alert(record.getName());
        },
    Now I can access record from my function, but if anyone knows how to pass extra param to handler function please let me know

  3. #2
    Sencha User Misiu's Avatar
    Join Date
    Jun 2012
    Location
    Poland
    Posts
    196
    Answers
    6
    Vote Rating
    31
    Misiu has a spectacular aura about Misiu has a spectacular aura about

      0  

    Default


    I've changed a bit my code:
    Code:
        onEventContextMenu: function (s, rec, e) {
            e.stopEvent();
    
            if (!s.ctx) {
                s.ctx = new Ext.menu.Menu({
                    items: [{
                        text: 'Delete event',
                        iconCls: 'icon-delete',
                        scope: this,
                        handler : function() {
                        Ext.MessageBox.show({
                                        title : 'Reason',
                                        msg : 'place reason:',
                                        width : 300,
                                        buttons : Ext.MessageBox.OKCANCEL,
                                        multiline : true,
                                        scope: this,
                                        fn : function(btn,text){ if (btn == 'ok') this.showResultText(rec);}
                                        //fn : this.showResultText(buttonId, text, rec)
                                    });
                        }
                    },{
                                text : 'Accept',
                                iconCls : 'accept',
                                handler : function() {
                                    alert(rec.getName());
                                }
                            }, 
                    ]
                });
            }
            s.ctx.rec = rec;
            s.ctx.showAt(e.getXY());
        },
        
        showResultText : function (record, reason){
                alert(record.getName());
        },
    Now I can access record from my function, but if anyone knows how to pass extra param to handler function please let me know

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