PDA

View Full Version : How to display waitMsg, success, failure on DataStore Loading?



missgextjs
4 Oct 2010, 3:06 AM
Anybody please help Y_Y . . .

I'm doing delete PARTNER function. Before delete, I have to check that PARTNER is related with other item or not. If it related I have to alert warning message but if not that PARTNER will go to delete process.

My problem is I didn't get any alert message although it success or fail.

In my PHP code return like this ..

if (success) {
echo "{success:true}";
} else {
echo "{success: false, errors: { reason: 'Update Failed!!' }}";
}


This is my EXTJS code.

PartnerDataStore.load({
url: './php/partner.php',
params: {
task: "DELETE_PARTNER",
partner_id: rec.get("partner_id")
},
waitMsg: 'Processing ...',
success: function(objServerResponse){
if(objServerResponse.responseText == 'success'){
Ext.MessageBox.alert('Success','Item deleted.');
}
},
failure : function(objServerResponse){
Ext.MessageBox.alert('Failed', 'Error : ' + objServerResponse.responseText);
}
});


What am I doing wrong? :(


Please help ...

sreenivasreddy
4 Oct 2010, 3:13 AM
Dispaly example avaliable in EXTJS Action PDF book go through find related more examles

laurentParis
4 Oct 2010, 3:47 AM
try this


PartnerDataStore.load({
url: './php/partner.php',
params: {
task: "DELETE_PARTNER",
partner_id: rec.get("partner_id")
},
waitMsg: 'Processing ...',
success: function(objServerResponse){
var resp = Ext.decode(objServerResponse.responseText);
if(resp.success){
Ext.MessageBox.alert('Success','Item deleted.');
}
else {
Ext.MessageBox.alert('Error','xxx');
}
},
failure : function(objServerResponse){ // << intercept only error http
Ext.MessageBox.alert('Failed', 'Error : ' + objServerResponse.responseText);
}
});

laurentParis
4 Oct 2010, 3:48 AM
try this :


PartnerDataStore.load({
url: './php/partner.php',
params: {
task: "DELETE_PARTNER",
partner_id: rec.get("partner_id")
},
waitMsg: 'Processing ...',
success: function(objServerResponse){
var resp = Ext.decode(objServerResponse.responseText);
if(resp.success){
Ext.MessageBox.alert('Success','Item deleted.');
}
else {
Ext.MessageBox.alert('Error','xxx');
}
},
failure : function(objServerResponse){ // << intercept only error http
Ext.MessageBox.alert('Failed', 'Error : ' + objServerResponse.responseText);
}
});

laurentParis
4 Oct 2010, 3:49 AM
Try this


PartnerDataStore.load({
url: './php/partner.php',
params: {
task: "DELETE_PARTNER",
partner_id: rec.get("partner_id")
},
waitMsg: 'Processing ...',
success: function(objServerResponse){
var resp = Ext.decode(objServerResponse.responseText);
if(resp.success){
Ext.MessageBox.alert('Success','Item deleted.');
}
else {
Ext.MessageBox.alert('Error','xxx');
}
},
failure : function(objServerResponse){ // << intercept only error http
Ext.MessageBox.alert('Failed', 'Error : ' + objServerResponse.responseText);
}
});

laurentParis
4 Oct 2010, 3:51 AM
failure intercept only http error

use Ext.decode for convert string objServerResponse.responseText into json format
and test it
[/code]
var resp = Ext.decode(objServerResponse.responseText);
if(resp.success){
Ext.MessageBox.alert('Success','Item deleted.');
}
else {
Ext.MessageBox.alert('Error','xxx');
}
[/code]

missgextjs
4 Oct 2010, 5:10 AM
Please give me an example ... :( ? ? ? ?

Condor
4 Oct 2010, 5:29 AM
1. Why are you loading a store? Why not use an Ext.Ajax.request?
2. Your response isn't 'success'; it's {success:true} (so I recommend Ext.decode'ing the responseText).

plalx
4 Oct 2010, 5:42 AM
Well... assuming your PartnerDataStore inherits from an Ext.data.*Store, you need to read the API Documentation about the load() (http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.Store) method... You will quickly understand what's wrong. You should use Ext.Ajax.request for this, the load() method of the Ext.data.Store is for retriving records... and it doesn't support success, failure or waitMsg config options.

missgextjs
4 Oct 2010, 9:29 PM
Many thanks about all answers that all you guy gave me :)

Now I got it. I should use Ext.Ajax.request instead .

Great !!!! ^o^