1

我使用 Ext.window.MeassageBox 作为确认对话框窗口。

代码是这样的:

deleteSomething: function( grid, row, col ) {
    var ids = [ grid.store.getAt( row ).get( 'id' ) ];

    function deleteSomething ( btn, text ) {
        if( btn === 'yes' ) {
            Ext.Ajax.request( {
                url: 'data/deleteSomething.php',
                params: {
                    'ids': Ext.encode( ids )
                },
                success: function( response ) {
                    //perform some actions
                }
            } );
        }
    }

    Ext.MessageBox.show( {
        animEl: 'elId',
        buttons: Ext.MessageBox.YESNO,
        fn: deleteSomething,
        msg: Locale.gettext( 'Are you sure you want to remove the selected thing?' ),
        title: Locale.gettext( 'Delete?' )
    } );
}

我想为消息字段和比例应用一些 css 规则:'medium',右侧对齐按钮。有没有办法在不扩展 MessageBox 的情况下实现它?

4

1 回答 1

2

Did you try to add buttons properties like below?

Ext.MessageBox.show({
   buttons: [
      {text: 'YES', scale: 'medium'},
      '->',
      {text: 'NO', scale: 'medium}
   ]
});

EDIT : why we don't use a simple window component?

var winDelete = new Ext.Window({
    width: 300,
    modal: true,
    closeAction: false,
    title: 'Are you sure to delete this record?',
    closable: false,
    html: '<span>The selected records will remove from the list.<br/>Are you sure?</span>',
    buttons: [
        {
            text: 'YES',
            scale: 'medium',
            cls: 'btn-delete-yes',
            listeners: {
                click: function() {
                    deleteSomething();
                }
            }
        }, '->',
        {
            text: 'NO',
            scale: 'medium',
            cls: 'btn-delete-no',
            listeners: {
               click: function() {
                   winDelete.close();
               }
            }
        }
    ]
});
于 2013-08-23T13:35:10.440 回答