简体   繁体   English

如何覆盖现代DatePicker的extjs

[英]How to override extjs modern DatePicker

In ExtJs 6.2.0 modern toolkit , the DatePicker is quite strange - it has three slots (day, month, year). ExtJs 6.2.0现代工具包中 ,DatePicker非常奇怪 - 它有三个插槽(日,月,年)。 But I really need to know the day of week for each date, like in normal datepickers. 但我真的需要知道每个日期的星期几,就像普通的日期采摘者一样。

How can I override existing DatePicker to highlight weekends or to write day of week somewhere near the day number? 如何覆盖现有的DatePicker以突出显示周末或在日期编号附近写一周的某一天?

I just solved this issue by using a custom date picker that changes the day's text any time a slot is changed. 我刚刚通过使用自定义日期选择器来解决此问题,该日期选择器可在任何时候更改插槽时更改日期文本。

Ext.define('App.field.DateDayPicker', {
    extend: 'Ext.field.DatePicker',
    alias: 'widget.datepickerdayfield',

    requires: [
        'App.picker.DateDay'
    ],

    picker: {
        xtype: 'datepickerday'
    }
});

Ext.define('App.picker.DateDay', {
    extend: 'Ext.picker.Date',
    alias: 'widget.datepickerday',

    onSlotPick: function () {
        this.callParent(arguments);

        var value = this.getValue();
        var store = this.daySlot.getStore();

        store.each(function (day) {
            var dayDate = day.get('value');
            var year = value.getFullYear();
            var month = value.getMonth();
            var date = new Date(year, month, dayDate);
            var text = Ext.Date.format(date, 'j D');

            day.set('text', text);
        });
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM