-
FEATURED COMPONENTS
First time here? Check out the FAQ!
How to set default year in datebox when the button is clicked
When the button is clicked, it always show the current year, any way to set other than current year ?
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>
Asked: 2018-08-29 17:35:09 +0800
Seen: 5 times
Last updated: Aug 30 '18