The last
Create Read Update Destroy (CRUD) operation that we need to implement is the delete user operation. So let's add the delete
listener to the controller:
"users button#delete": { click: this.onButtonClickDelete }
When the user clicks on the Delete button, the controller will execute the
onButtonClickDelete
method.
onButtonClickDelete: function (button, e, options) { var grid = this.getUsersList(), record = grid.getSelectionModel().getSelection(), store = grid.getStore(); if (store.getCount() >= 2 && record[0]){ // delete logic here } else if (store.getCount() == 1) { Ext.Msg.show({ title:'Warning', msg: 'You cannot delete all the users from the application.', buttons: Ext.Msg.OK, icon: Ext.Msg.WARNING }); } }
The idea of this method is to verify if the user selected any row from the grid to be deleted (record[0]
exists); and also, we will only delete...