View Full Version : Deleting grid record using cellclick

2 May 2011, 10:37 PM
I'm developing an application in which I want to place a grid in the centre region on the click of a button, placed in the west region. The selection model fails to work when the grid is reload when the button is clicked again. I'm using a tab panel for the centre, which does removeAll() and add() methods to load set of tabs for the menu buttons.
The issue I want to clarify is how to delete a row of the grid and also in database when the user clicks on the delete icon image placed in one of the columns of the grid. I was trying to do so using 'listeners' and 'cellclick' concepts.
The portion of the code is as follows,

var griduser = {
xtype: 'grid',
//x: 25, border: false,
//width: 792, height: 450,
id: 'usertable',
store: storeuser,
trackMouseOver: false,
listeners: {
cellclick: function(o,row,col,e) {
if (col == 6) {
msg: 'Do you really want to delete this user?',
buttons: Ext.MessageBox.YESNO,
fn: function(btn){
if (btn == 'yes'){
var conn = new Ext.data.Connection();
url: 'user_delete.php',
params: {
action: 'delete',
id: e.record.id,
row: e.row
success: function(resp,opt) {
Ext.Msg.alert('Success', 'Selected user has been deleted');
failure: function(resp,opt) {
'Unable to delete movie');
columns: [
{header: "Login", dataIndex: 'login_id', width: 110},
{header: "Name", dataIndex: 'Name', width: 160},
{header: "Email Id", dataIndex: 'email', width: 210},
{header: "Group", dataIndex: 'group_name', width: 120},
{header: "Send Email", dataIndex: 'email', renderer: renderIcon, width: 70},
{header: "Edit", dataIndex: 'Edit', renderer: editIcon, width: 60},
{header: "Delete", dataIndex: 'Delete', renderer: deleteIcon, width: 60}
function deleteIcon(value, p, record) {
p.attr = 'ext:qtip="<b>Delete</b>"';
return (value, '<img src="images/icon_delete.png" >') ;
The php file for deleting the selected row,

mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

mysql_query ("DELETE FROM users WHERE user_id = '".$_REQUEST['id']."'");