PDA

View Full Version : about gridpanel, how to store a number of record rows into database ?



sunrong
26 Aug 2010, 6:46 PM
hi all,
for there is only one record,
var conn = new Ext.data.Connection();
conn.request({
url: 'index.php?model=salary&action=savegrid&',
params:{
username: username
.......
},
success: function(resp, opt){
// gridexcel.store.remove(r);
Ext.Msg.alert('ok');
}
});

but for there are many row,
i write like this.

var ds = gridexcel.getStore();
ds.each(function(r){
var conn = new Ext.data.Connection();
conn.request({
url: 'index.php?model=salary&action=savegrid&',
params:{
username: username
.......
},
success: function(resp, opt){
gridexcel.store.remove(r);
// Ext.Msg.alert('ok');
}
});

Ext.Msg.alert('ok');
}

for Ext.data.Connection is asynchronous, Ext.Msg.alert('OK') dispalys before connection is done.
i try

success: function(resp, opt){
gridexcel.store.remove(r);
if (last row) {
Ext.Msg.alert(OK);
}
}
but the effect becomes worse.

could someone give one samples or how to improve it?