当前位置:首页 > 开发 > Web前端 > 前端 > 正文

rich:calendar to show only month and year

发表于: 2013-11-06   作者:sunjing   来源:转载   浏览:
摘要: 方案一 <rich:calendar id="coco" value="#{eventTrackingAction.query.month}" showWeeksBar="false"            &n

方案一

<rich:calendar id="coco" value="#{eventTrackingAction.query.month}" showWeeksBar="false"
               showFooter="false" datePattern="MMM,yyyy" styleClass="calendar-month"
               oncurrentdateselect="setMonth();"/>


<h:outputScript target="head">
    function setMonth() {
    var calendar = #{rich:component('coco')};
    var year = calendar.getCurrentYear();
    var month = calendar.getCurrentMonth();
    calendar.setValue(new Date(year,month,1));
    }
</h:outputScript>

 

.calendar-month tr[id] {
    display: none;
}

 

方案二

<ios:calendar value="#{eventTrackingAction.query.month}" id="month" required="true"
              datePattern="MMM,yyyy" oncurrentdateselect="setMonth();"
              rendered="#{eventTrackingAction.query.frequency == 'MONTH'}"/>

<rich:jQuery selector="#month .rf-cal-inp,#month .rf-cal-btn" query="unbind('click')"/>
<rich:jQuery selector="#month .rf-cal-inp,#month .rf-cal-btn" event="click" query="showDateEditor()"/>
<h:outputScript target="head">
    function showDateEditor() {
        #{rich:component('month')}.showDateEditor();
        var input = jQuery("#queryForm\\:monthInputDate");
        var position = input.position();
        var height = input.outerHeight(true);
        var top = position.top + height;
        var left = position.left;

        var monthEditor = jQuery("#queryForm\\:monthEditor")
        var monthEditorShadow = jQuery("#queryForm\\:monthEditorShadow")
        monthEditor.height(158);
        monthEditor.offset({top:top,left:left});
        monthEditorShadow.height(158);
        monthEditorShadow.offset({top:top,left:left});
        jQuery("#queryForm\\:monthDateEditorLayout").width(225);
        jQuery("#queryForm\\:monthEditorLayoutShadow").width(225);
    }

    function setMonth() {
        var calendar = #{rich:component('month')};
        var year = calendar.getCurrentYear();
        var month = calendar.getCurrentMonth();
        calendar.setValue(new Date(year,month,1));
    }
</h:outputScript>

rich:calendar to show only month and year

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号