简体   繁体   中英

how to disable day in Datebox using Zk

I have changed color on selected date

You can find zk fiddle here

Now i want disable day. It should not be clickble.

Currently the enable/disable of a date is rely on its css class, you can add Datebox.getZclass()+'-disd' to disable it at client side, please refer to the sample at zkfiddle:

How to disable day in Datebox in Zk

This way you can save some au request, but still need to add server side validation properly for set date by java API.

The datebox constraint is based on SimpleDateConstraint which only supports a date range unfortunately: you cannot black out specific dates in this manner.

I believe the correct way to do this is not to make the date un-selectable in the UI, per se, but to ignore the date when it is selected. Combining this with visually blacking out the date like you've done already, and you'll get the effect you are looking for.

To do this on the Java side you can implement a custom ClientConstraint . This will actually validate your input values in JavaScript, as opposed to the normal server-side Constraint .

You can, of course, dig into the Datebox JavaScript widget itself but I tend to shy away from that approach when possible. In fact, you'll see the datebox.validate_ function bridges this gap for you by integrating the aforementioned ClientConstraint .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM