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
2615 3 8

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

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

cor3000 gravatar image cor3000
4466 2 7
ZK Team

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">
    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();
    <datebox w:defaultYear="2010"/>
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

1 follower



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

Seen: 4 times

Last updated: Aug 30 '18

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