Ext js popup如何使其工作?在行动链接

时间:2013-06-12 07:25:22

标签: extjs grid popup action messagebox

我如何才能使它发挥作用?

我想在我的网格中添加删除图标,就像带有弹出窗口的栏目确认一样。 你想删除x项?

做了这样的事情,但它不起作用

{
             xtype: 'actioncolumn',
             width: 50,
             items: [
                {
                    icon: 'delete.gif',                // Use a URL in the icon config
                    tooltip: 'Delete Product',
                    handler: function (grid, rowIndex, colIndex) {
                        var rec = store.getAt(rowIndex);
                        var id = rec.get('ID');

                        Ext.MessageBox.show({
                            title: 'Save Changes?',
                            msg: 'Do you want to delete ' + rec.get('Name') + ' ?',
                            buttons: Ext.MessageBox.OKCANCEL,
                            fn: showResult


                        });


                    }
                }
            ]
         }

2 个答案:

答案 0 :(得分:2)

使用confirm代替show

Ext.MessageBox.confirm('Save Changes?', 'Do you want to delete ' + rec.get('Name') + ' ?', function(r) {
    if (r == 'yes') {
        rec.destroy();
    }
});

答案 1 :(得分:1)

对于OKCANCEL按钮:

handler: function (grid, rowIndex, colIndex) {
            var rec = grid.store;
            Ext.MessageBox.show({
                title: 'Address',
                msg: 'Do you want to delete ?',
                buttons: Ext.MessageBox.OKCANCEL,
                fn: function showResultText(btn) {
                        if (btn == 'ok') {
                            rec.removeAt(rowIndex);
                        }
                    }
                });


            }