PDA

View Full Version : After closing window reload store



Dannesart
14 Nov 2011, 8:17 AM
After I've closed a dialog I want to reload my grid.

Grid:



loadGridData: function(companyNo) {
//cache param for future reloads
this.companyNo = companyNo;
var selectedDate = this.getSelectedDate();
var dateFrom = Ext.Date.getFirstDateOfMonth(selectedDate);
// var dateTo = Ext.Date.getLastDateOfMonth(selectedDate);

this.loadStore(companyNo, dateFrom);
// this.loadStore(companyNo, dateFrom, dateTo);


},




showConfirmationDialog: function(empNo) {
var dialog = Ext.create('Intelliplan.Modules.Staffing.BookEmployee.Consultant.Shift.BookingConfirmationDialog',
{
consultantEmpNo: empNo
}
);
// dialog.add();
dialog.show();

},


dialog:


Ext.define('Intelliplan.Modules.Staffing.BookEmployee.Consultant.Shift.BookingConfirmationDialog', {
extend: 'Intelliplan.Modules.Staffing.BookEmployee.Consultant.Shift.BookingConfirmationDialogUi',
consultantEmpNo: undefined,
initComponent: function () {

this.callParent(arguments);
this.defineReferences();

//handlers
this.sendMailDialogButton.on('click', this.onSendMailDialogButtonClick, this);
this.sendSmsDialogButton.on('click', this.onSendSmsDialogButtonClick, this);
this.clearConfirmationNeedButton.on('click', this.onClearConfirmationNeedButtonClick, this);
this.emailConfirmation.on('emailConfirmationSent', this.onEmailConfirmationSent, this);
this.smsConfirmation.on('smsConfirmationSent', this.onSmsConfirmationSent, this);
this.bookShiftGrid.on('selectedRestransKeysChanged', this.onSelectedRestransKeysChanged, this, {buffer: 2000});

},
defineReferences: function() {
this.emailConfirmation = this.down('#emailConfirmation');
this.sendMailDialogButton = this.down('#sendMailDialogButton');
this.bookShiftGrid = this.down('#bookShiftGrid');
this.smsConfirmation = this.down('#smsConfirmation');
this.sendSmsDialogButton = this.down('#sendSmsDialogButton');
this.clearConfirmationNeedButton = this.down('#clearConfirmationNeedButton');
this.getBottomToolbar().cancelButton = this.getBottomToolbar().down('#cancelButton');

},

onCancelButtonClick: function() {
this.close();

},

onSendMailDialogButtonClick: function () {
if (!this.bookShiftGrid.checkRowIsSelected())
return;
// var data = {
// empNo: this.consultantEmpNo,
// resTransKeys: this.bookShiftGrid.selectedResTransKeys
// };
this.emailConfirmation.sendEmailConfirmation(this.bookShiftGrid.selectedResTransKeys);
},
onSendSmsDialogButtonClick: function () {

if (!this.bookShiftGrid.checkRowIsSelected())
return;
// var data = {
// empNo: this.consultantEmpNo,
// resTransKeys: this.bookShiftGrid.selectedResTransKeys
// };

this.smsConfirmation.sendSmsConfirmation(this.bookShiftGrid.selectedResTransKeys);
},


onEmailConfirmationSent: function() {
this.refreshBookShiftGrid();
},
onSmsConfirmationSent: function() {
this.refreshBookShiftGrid();
},
onClearConfirmationNeedButtonClick: function() {
if (!this.bookShiftGrid.checkRowIsSelected())
return;

var url = Intelliplan.Api.BaseUrl + '/Staffing/ConsultantConfirmation/DeleteConfirmationNeed'

var data = {
empNo: this.consultantEmpNo,
resTransKeys: this.bookShiftGrid.selectedResTransKeys
};

var errorMessage = IPtranslate('Intelliplan.Common.Messaging.Mail.Standard.TemplateGenerationErrorMessage');
Intelliplan.Util.Ajax.post(url, data, true, function() {
this.refreshBookShiftGrid();
}, errorMessage, this);
},
refreshBookShiftGrid: function() {
this.bookShiftGrid.loadStore();
this.bookShiftGrid.view.refresh();
},
onSelectedRestransKeysChanged: function() {
// var data = {
// empNo: this.consultantEmpNo,
// resTransKeys: this.bookShiftGrid.selectedResTransKeys
// };

this.smsConfirmation.generateReportChange(this.bookShiftGrid.selectedResTransKeys);
this.emailConfirmation.generateReportChange(this.bookShiftGrid.selectedResTransKeys);
}
});


any Ideas?

tvanzoelen
14 Nov 2011, 8:22 AM
I dont know what your dialog is extending, but if it is a window, try this.


closeAction: 'hide' on your dialog.

Dannesart
14 Nov 2011, 8:26 AM
No it didn't work :/

tvanzoelen
14 Nov 2011, 8:47 AM
Sorry didn't read your question well, I thought you got a problem while reloading it but youre not in that stage yet.

I think on the close event of your dialog, get your store and call its function store.load();

so what is your question or problem? What doesn't work?

Dannesart
14 Nov 2011, 8:53 AM
In my dialog I got a cancel button, when I press it the dialog close:

onCancelButtonClick: function() {
this.close();

},

And when it close I wanted to reload the grid store.

Maby something you said: "get your store and call its function store.load(); "

tvanzoelen
14 Nov 2011, 9:19 AM
Yes, if you are in the onCancelButtonClick you can reference and load youre store like this




var store = Ext.data.StoreManager.lookup('myStore');
store.load({
params: yourparams,
scope : this,
callback: function(records, operation, success) {
//the operation object contains all of the details of the load operation
console.log(records);
}
});



But you must put a storeId on your store, else storeManager can not find it.



Ext.create('Ext.data.Store', {
model: 'SomeModel',
storeId: 'myStore'
});

Dannesart
14 Nov 2011, 11:58 PM
Thank you! It works excellent!