ramiromd
ramiromd

Reputation: 2029

Custom dialogs extjs

Im try write custom dialogs, for my app. I think wrote a subclass of Ext.window.MessageBox, and pass by parameters the title and message. And i wrote:

Ext.define('CRUDManantiales.view.dialog.NoUserSelected',{
    extend: 'Ext.window.MessageBox',
    alias: 'dialog.noUserSelected',

    initComponent: function(){
        this.title = this.titulo;
        this.msg = 'No se ha seleccionado ningún usuario.\n Asegurese de haber elegido un usuario\n\
                           al cual aplicarle la operación.';
        this.buttons = Ext.MessageBox.OK;
        this.icon = Ext.MessageBox.ERROR;
        this.callParent(arguments)
    }
})

But when create and show the dialog:

Ext.create('CRUDManantiales.view.dialog.NoUserSelected',{titulo: 'Agregar administrador'}).show();

Firebug says:

TypeError: cfg is undefined on MessageBox.js
"NetworkError: 404 Not Found - http://appadmin.local/x-message-box-error"

Any idea ? Note: im using ExtJs 4.1

Upvotes: 2

Views: 1549

Answers (1)

Vlad
Vlad

Reputation: 3645

You need to pass an config object to the method Ext.Msg.show(cfg), not set the component config.

You can write custom method, as:

...
initComponent: function(){
    this.callParent(arguments)
},

showError: function() {
    var cfg = {
        title: this.titulo,
        msg: 'No se ha seleccionado ningún usuario.\n Asegurese de haber elegido un usuario\n\al cual aplicarle la operación.',
        buttons: Ext.MessageBox.OK,
        icon: Ext.MessageBox.ERROR
    };
    this.show(cfg);
}
...

And show dialog:

Ext.create('CRUDManantiales.view.dialog.NoUserSelected',{titulo: 'Agregar administrador'}).showError();

Upvotes: 2

Related Questions