Dox
Dox

Reputation: 158

Ext js popup How make it work ? in action link

How Can I make it work ?

I want put delete icon in my grid like a columnaction with popup to confirm. You want to delete x item ?

made something like this but its not working

{
             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


                        });


                    }
                }
            ]
         }

Upvotes: 0

Views: 410

Answers (2)

Dev
Dev

Reputation: 3932

For OKCANCEL buttons :

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);
                        }
                    }
                });


            }

Upvotes: 1

Greendrake
Greendrake

Reputation: 3734

Use confirm instead of show:

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

Upvotes: 2

Related Questions