如何更改 EXTJS 日历中的移动间隔?

How to change move interval in EXTJS calendar?

如何在 EXTJS 日历(现代工具包)中更改移动间隔?

我想查看周视图,并按 30 天更改值。

默认情况下,此移动间隔设置为 7 天。此外,还有一个 属性 getMoveInterval 要移动的 returns 个单位和要移动的单位数 {unit: "d", amount: 7}。但是,没有setMoveInterval.

这样的东西

在理想情况下,我希望将此配置设为 {unit: "m", amount: 1}

我试图更改 valuechange 周视图事件中的值:

valuechange: function (a){
    //some calculations to calculate newDate;
    a.setValue(newDate);
}       

但后来我陷入了无限循环:

Uncaught RangeError: Maximum call stack size exceeded

另一方面,我没有看到任何其他合适的方法来检测更改显示的日期间隔。

您只能通过为周或月覆盖以下 class 来实现(工作周具有相同的功能...):

Ext.define('MyApp.overrides.calendar.view.Week', {
    override: 'Ext.calendar.view.Week',

    privates: {
        getMoveInterval: function() {
            var D = Ext.Date;
            return {
                unit: D.DAY,
                amount: 30    // D.DAYS_IN_WEEK
            };
        }
    }
});

Ext.define('MyApp.overrides.calendar.view.Month', {
    override: 'Ext.calendar.view.Month',

    privates: {
        getMoveInterval: function() {
            return {
                unit: Ext.Date.MONTH,
                amount: 6            // 1
            };
        }
    }
});

因为 getMoveInterval 是私有函数,所以您必须这样覆盖它。