Posts Tagged ‘get selection’

Delete selected rows in Grid

July 27th, 2013 No comments

Here’s an example of how to delete selected row in the Grid object:

I guess that somewhere you have a button that will click to perform the action. In this example, it is a button located in the toolbar on the grid object

tbar : [{
    iconCls: 'cross- line ',
    text: 'Delete',
    tooltip:{ title:'Delete Rows' , text: 'Delete selected rows' },
    handler : function(ths, e)
       Ext.Msg.confirm('Delete Confirmation', 'Delete selected rows?', function(btn)
            if (btn == 'yes') {
                store_object.remove( ths.up('grid').
                                         getSelection() );

If the user confirms delete, the selected rows will be removed from the store. In order to reach the selected rows is necessary to pass through the structure.

“ths” variable is the first in a series. She points to the button that we clicked. The button is part of the grid toolbar. The function up (‘grid’) take the first grid that is above it in the hierarchy (the parent). In a similar way you can request other objects, e.g. tree or form. When you get the grid object, pass through it and take the selected rows.