PDA

View Full Version : Remove records from store without remove from view



jconcept
30 Mar 2012, 12:29 PM
I have a gridpanel with multiselection, a remove button and a save button.
The handler for remove button do this:


var selection = this.getSelectionModel().getSelection();
if (selection) {
this.store.remove(selection);
}

and the handler for save button do this:



Ext.Object.merge(this.store.proxy.extraParams, {
validate : validate
});
this.store.sync();


The sync action call a db function that have some validations before delete records, if there is any error then dont delete the selected records and send back the validations.

My issue is the records remaing deleted from the store and view.

Is there anyway to handler this?
I dont know, may be remove from the store and not from the view ? or some "rollback" from deleted records?

Thanks a lot

scottmartin
30 Mar 2012, 3:12 PM
Try using an AJAX call to remove the records.



var recs = [];
for (var i = 0, rec; rec = selRows[i]; i++){
recs.push({ id: selRows[i].data.id_request });
}
// ajax call to delete all id instead of multiple calls to store.remove
Ext.Ajax.request({
method: 'POST',
url: 'delete_records.php',
params : {
ids: Ext.encode(recs) // list of recs
},
success: function(xhr) {
// check for success in return xhr
var jsonResp = Ext.decode(xhr.responseText)
},
failure: function() {
alert('AJAX FAILURE: Unable to delete selected recs');
}
});

// update view if successfull
store.load();


Regards,
Scott.

jconcept
18 Apr 2012, 10:29 AM
I am using crud actions in the store, and all request are handler by the save button calling the sync method.
I would like keep it.
żIt is possible?