PDA

View Full Version : How do I reload store from different window



hellosudhir
3 Aug 2010, 9:26 PM
Hi,

this is my scenario:
I've GridPanel inside View Port which has double click event to open a new window for a corresponding record that is double clicked. Now when i change the record in the new window( record's field change or delete record itself) i need to reload the store for the GridPanel to reflect the changes just made from window. i was trying to access the Gridpanel's store using its autoRef without any success.

this is what i did so far:

onDeleteButtonClick:function(e, t)
{

var transaction_key=this.Trans_key;
Ext.Msg.confirm( 'Delete Order', 'Are You sure you want to Delete this order?',function(btn)
{
if(btn === 'yes'){

//if the user has accepted
Ext.Ajax.request({
url: '/4DACTION/web_build_json_data/'+SessionID+'/DeleteOrder/',
method: 'POST',
params: {Trans_key:transaction_key},
success: function ( result, request) {

Ext.MessageBox.alert('Success', 'Order has been deleted.');
this.OrderGrid.getStore().reload();

this.close();


},
failure: function ( result, request) {
Ext.MessageBox.alert('Failed', 'Connection aborted');
}
//scope: this

});

}else{
//if the user has canceled
}


});

}

underlined text is what i did to reload the sore of Gridpanel and 'OrderGrid' is the autoRef of that grid.
but it say OrderGrid is not defined. i don't know what is wrong.
any help would be appreciated.

thanks.

Condor
4 Aug 2010, 12:38 AM
1. What is 'this'. Did you set the scope correctly?
2. I would handle this differently:
The window doesn't need to know anything about the grid, it should just fire a custom event ('orderdeleted'?). The component that holds the grid would then attach a 'orderdeleted' event handler to the window that does a grid reload.