2013-08-23 78 views
0

使用Ext.window.MeassageBox作爲確認對話窗口。自定義Ext.window.MessageBox ExtJS 4

代碼是這樣的:

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規則:「中」與右側對齊的按鈕。有沒有任何方法來實現它沒有擴展MessageBox?

回答

2

您是否嘗試添加buttons屬性,如下所示?

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

編輯: 爲什麼我們不使用一個簡單的window成分?

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(); 
       } 
      } 
     } 
    ] 
}); 
+0

看來它不工作 - 按鈕就此消失。 –

+0

只要刪除' - >'部分,然後再試一次。如果它的工作爲css類添加cls參數。修改類浮動:右 –

+0

Ext.MessageBox.show({ \t \t ANIMEL: 'ELID', \t \t按鈕:[ \t \t \t { \t \t \t \t文本: '是' \t \t \t} , \t \t \t { \t \t \t \t文本: 'NO' \t \t \t} \t \t], \t \t FN:deleteRule, \t \t消息:Locale.gettext( '?您確定要刪除選定的事'), \t \t標題:Locale.gettext('刪除?') \t}); 即使它不起作用 - 按鈕仍然消失,也許我做錯了什麼? –