PDA

View Full Version : Deleting data from the server



vzhen
25 Sep 2009, 2:38 AM
Hi,
I am learning from Learning-Extjs 2.0 book. The deleting data not working. I can't figure it out. It only works when i change to "client side remove" id: e.record.id to id: sel.data.id in tbar.

Note: I use the php code provided in learning-extjs 2.0
Need help thx

Chapter 6 (editor grids)
part - deleting data from the server

This is the listeners inside EditorGridPanel

listeners: {
afteredit: function (e) {
var conn = new Ext.data.Connection();
conn.request({
url: 'movies-update.php',
params: {
action: 'update',
id: e.record.id,
field: e.field,
value: e.value
},
success: function (resp, opt) {
e.commit();
},
failure: function (resp, opt) {
e.reject();
}
});
}
}




And here is the handler under tbar remove button

{
text: 'Remove Movie',
icon: 'images/table_delete.png',
cls: 'x-btn-text-icon',
handler: function () {
var sm = grid.getSelectionModel();
var sel = sm.getSelected();
if (sm.hasSelection()) {
Ext.Msg.show({
title: 'Remove Movie',
buttons: Ext.MessageBox.YESNOCANCEL,
msg: 'Remove ' + sel.data.title + '?',
fn: function (btn) {
if (btn == 'yes') {
var conn = new Ext.data.Connection();
conn.request({
url: 'movie-update.php',
params: {
action: 'delete',
id: e.record.id
},
success: function (resp, opt) {
grid.getStore().remove(sel);
},
failure: function (resp, opt) {
Ext.Msg.alert('Error', 'Unable to delete movie');
}
});
}
}
});
};
}
}

27 Sep 2009, 6:29 PM
What is "e.record.id"??

it should be sel.data.id