0

我想要这样的东西:

{
  xtype:'datefield',
  editable:false,
  fieldLabel:'date',
  listeners:{
    monthChange:function(picker){
      alert("selected month and year")
    }
  }
}

换月有什么活动吗?如果没有,我该怎么写?

谢谢

4

2 回答 2

3

这是扩展 'Ext.date.Picker' 的示例,因为没有 'monthchange' 事件:

Ext.define("YourCalendarPicker", {
    extend: "Ext.picker.Date",
    ...
    update : function(date, forceRefresh){
        var me = this,
            monthViewChange = me.isAnotherMonthView(date);
        me.callParent(arguments);
        if (monthViewChange){
            me.fireEvent("monthviewchange", me, date, me.activeDate);
        }
        return me;
    },
    ...

    /**
     * return true if the given date is in a different month view of the actual calendar date
     * @param {Date} date
     * @return {Boolean}
     */
    isAnotherMonthView: function(date){
        var activeDate = this.activeDate || date;
        return date.getYear() != activeDate.getYear() || date.getMonth() != activeDate.getMonth();
    }
};
于 2014-01-13T12:44:26.117 回答
1

确实没有monthChange事件,但是您可以在有人选择新日期时收听,然后也许您可以比较月份以查看它是否改变了? http://docs.sencha.com/ext-js/4-1/#!/api/Ext.picker.Date-event-select

如果这不是您要解决的问题,更多信息会有所帮助。

于 2012-07-09T04:36:06.650 回答