【问题标题】:ExtJs Calendar store load help?ExtJs 日历存储加载帮助?
【发布时间】:2011-07-03 11:08:34
【问题描述】:

我已经设置了一个 ExtJs 日历。然而,即使我没有调用 store.load 方法,商店最初也会加载 4 次。我只是想知道这是从哪里调用的?因为它还会以错误的格式向服务器发送开始日期和结束日期。即它以 m/d/y 格式发送日期,而服务器期望 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'}]
});

日历:

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, dateInfo){
                    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
            }
    }

});

我认为 load 方法是从 Calendar-all.js 文件中调用的。但是我找不到确切的位置? 我可以拦截这些加载调用以确保日期格式正确吗?

【问题讨论】:

标签: extjs calendar load store


【解决方案1】:

是的,您可以在日历中停止初始加载存储。即使我们已将其设置为自动加载,它的加载:false。

examples/calendar/src/view/AbstractCalendar.js 第 717 行 注释代码

 /*this.store.load({
  params: {
     start: Ext.Date.format(this.viewStart, 'm-d-Y'),
     end: Ext.Date.format(this.viewEnd, 'm-d-Y')
   }

});*/

现在额外的加载停止,您可以随时执行存储。 :)

【讨论】:

    【解决方案2】:

    这是 Ext 3.3 示例版本中的一个错误。每个视图加载(月/周/天)都会导致单独的存储加载调用。这(以及许多其他内容)已在组件的 Ext Calendar Pro 版本 (examples here) 中修复。日期格式也可以在 Pro 版本中通过 CalendarView.dateParamFormat 配置进行配置。您当然可以自己解决这些问题,但我建议您试用 Pro 版本,看看它是否更适合您的需求。

    【讨论】:

    • 谢谢您,您知道日历是否会有年度视图?或者这可能吗?
    • 它在路线图上,但目前还没有计划。到目前为止,社区最需要的功能是最高优先级。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多