0

How to set default year in datebox when the button is clicked

asked 2018-08-29 17:35:09 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

How to set default year in datebox when the button is clicked image description

When the button is clicked, it always show the current year, any way to set other than current year ?

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-08-30 17:16:10 +0800

cor3000 gravatar image cor3000
6280 2 7

the datebox calendar popup will default to today's date unless a date is already set in the datebox.

This zkfiddle shows a simple way, switching to a different year when the calendar popup opens on an empty datebox.

<zk xmlns:w="client">
    <script><![CDATA[
    zk.afterLoad('zul.db', function() {
        var xCalendarPop = {};
        zk.override(zul.db.CalendarPop.prototype, xCalendarPop, {
            open : function() {
                var db = this.parent;
                var oldDate = db.getValue();
                xCalendarPop.open.apply(this, arguments);
                if(db.defaultYear && !oldDate) {
                    var initialDate = this.getValue();
                    initialDate.setFullYear(db.defaultYear);
                    this.setValue(initialDate);
                }
            }
        });//zk.override
    });//zk.afterLoad
    ]]></script>
    <datebox w:defaultYear="2010"/>
</zk>
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2018-08-29 17:35:09 +0800

Seen: 5 times

Last updated: Aug 30 '18

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More