ExtJs Calendar store load help?
I have set up an ExtJs calendar. However the store gets loaded 4 times initially even though I have not called the store.load method. I'm just wondering where this is getting called from? As it is also sending start and end dates in the wrong format to the server. i.e. it sends dates in the format m/d/y whilst the server expects d/m/y?
this.eventStore = new Ext.data.JsonStore({
id: 'eventStore',
root: 'Data.items',
proxy: new Ext.data.HttpProxy({
url: AppRootPath + 'Calendar/GetCalendarData',
method: 'POST'
}),//proxy
fields: [
{name:'StartDate', mapping: 'start', type: 'date', dateFormat: 'd F Y'},
{name:'EndDate', mapping: 'end', type: 'date', dateFormat: 'd F Y'},//H:i:s
{name:'Title', mapping: 'title', type: 'string'},
{name:'Notes', mapping: 'notes', type: 'string'},
{name:'CalendarId', mapping: 'cid', type: 'string'}]
});
The Calendar:
this.calendar = new Ext.calendar.CalendarPanel({
activeItem: 2,
id: 'calendar',
eventStore: this.eventStore,
calendarStore: this.calendarStore,
headerCfg: {
tag: 'center',
cls: 'x-panel-header x-unselectable'
},
monthViewCfg: {
showHeader: true,
showWeekLinks: true,
showWeekNumbers: true
},
title: 'My Calendar', // the header of the calendar, could be a subtitle for the app
listeners: {
'eventclick': {
fn: function(vw, rec, el){
alert('@EventClicked');
debugger
},
scope: this
},
'dayclick': {
fn: function(vw, dt, ad, el){
alert('@DayClicked');
},
scope: this
},
'viewchange': {
fn: function(p, vw, dat开发者_如何学编程eInfo){
updateTitle.apply(this, [dateInfo.viewStart, dateInfo.viewEnd]);
Ext.getCmp('app-nav-picker' + config.id).setValue(dateInfo.activeDate);
},
scope: this
},
'eventmove': {
fn: function(vw, rec){
rec.commit();
//var time = rec.data.IsAllDay ? '' : ' \\a\\t g:i a';
//this.showMsg('Event '+ rec.data.Title +' was moved to '+rec.data.StartDate.format('F jS'+time));
},
scope: this
}
}
});
I presume the load method is being called from the Calendar-all.js file. However I cant find exactly where? Can I intercept these load calls to ensure the dates is in the correct format?
This is a bug in the Ext 3.3 example version. Each view load (month / week / day) causes a separate store load call. This (along with lots of other stuff) has been fixed in the Ext Calendar Pro version of the components (examples here). The date format is also configurable in the Pro version via the CalendarView.dateParamFormat
config. You can certainly fix those things yourself, but I'd recommend that you try out the Pro version and see if it suits your needs better out of the box.
Yes you can stop that initially loading store at calender.. Its loading even thought we have made it autoload: false.
examples/calendar/src/view/AbstractCalendar.js Line#717 comment the code
/*this.store.load({
params: {
start: Ext.Date.format(this.viewStart, 'm-d-Y'),
end: Ext.Date.format(this.viewEnd, 'm-d-Y')
}
});*/
now extra loading stop and u can execute store whenever u want. :)
精彩评论