Omar Faruq
Omar Faruq

Reputation: 1220

Set focus on form field in extjs when press alert ok button

I want set focus in a number field in extjs when I press alert ok button but i cant do it i try this system. here is my code

Ext.Msg.alert("Invoice",'Invoice Id &nbsp'+invno + '&nbsp  is not Available');  
                        Ext.getCmp('InvoiceNo').focus(true);

and my number field is

{
        xtype             : 'numberfield',                
        hideTrigger       : true,
        decimalPrecision  : 0,
        keyNavEnabled     : false,
        mouseWheelEnabled : false,
        fieldLabel        : 'InvoiceNo',
        id                : 'InvoiceNo',
        name              : 'InvoiceNo',
        enableKeyEvents   : true,                           
        //minValue          : 1,
        msgDisplay        : 'tooltip',
        anchor            : '95%',
        }

Upvotes: 2

Views: 2244

Answers (1)

Omar Faruq
Omar Faruq

Reputation: 1220

I can do it by this process.

 var v = Ext.getCmp('InvoiceNo').getValue();
Ext.Msg.confirm('InvoiceNo','InvoiceNo'+v , function (button) {
  var InvoiceNo = Ext.getCmp('InvoiceNo');
    if (button == 'yes') {
        setTimeout(function(){
            InvoiceNo.setValue(v);
            InvoiceNo.focus(true)[0];
        },100);                             
    }                                
}, this);

Upvotes: 3

Related Questions