0

Implement an own Datebox component

asked 2008-07-08 14:51:16 +0800

enixser gravatar image enixser
185 3

Hi,

I want to implement a derived version of the Datebox component where only certain dates should be selectable. Could you please give some advice to me where I should look into to find the place where the content of the Calendar is rendered? I guess this would be the place where to check if a single day should be a link (selectable) or only a simple text (not selectable).

Best regards,
Ralf.

delete flag offensive retag edit

9 Replies

Sort by ยป oldest newest

answered 2008-07-09 02:22:50 +0800

zanyking gravatar image zanyking
99

take a look at this:

 
<window>
 between 2007/12/03~2007/12/25 : <datebox constraint="between 20071225 and 20071203"/><separator/>
 before 2007/12/25 : <datebox constraint="before 20071225"/><separator/>
 after 2007/12/03 : <datebox constraint="after 20071203"/><separator/>
</window>

link publish delete flag offensive edit

answered 2008-07-09 08:27:04 +0800

enixser gravatar image enixser
185 3

Unfortunately, this will not help in my case. I need a calendar where, let's say, each week every monday and friday is a valid date and all other days are not. My first thought as I read the docs about constraints was to use a custom constraint, but as far as I understood this will only be used for validating when a date is selected and written into the text field. It is not used for deciding if a day in the calendar is a link or not.

So, I looked a bit deeper into the source code and found the JavaScript file db.js. Here, I found the function _invalid of the zk.Cal class which decides if a date is valid (a link) or not.

So, my question is: Is it possible to override only this function to achieve the required behavior? And if yes, how do I have to do this in my code?

Best regards,
Ralf.

link publish delete flag offensive edit

answered 2008-07-10 16:51:36 +0800

enixser gravatar image enixser
185 3

I want to ask again for any suggestions by the ZK experts:

Is there a way to override the mentioned JavaScript function in the file db.js that checks if a single date of the calender is valid or not? If yes, this would be the solution for my problem (I hope :-). I should solve this problem by end of this week or I should at least know that I can't solve it. So, any help would be appreciated.

Best regards and thanks,
Ralf.

link publish delete flag offensive edit

answered 2008-07-13 14:58:41 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

Theoretically, you can override the javascript method and implement it your way.

link publish delete flag offensive edit

answered 2008-07-14 06:25:11 +0800

enixser gravatar image enixser
185 3

Hi Henri,

how can this be done for the _invalid function? Will it work if I put the following code into a separate JS file:

zk.Cal.prototype = {
_invalid: function (now) {
// here comes my new code
}
}

I have not ever done this, overriding a function inside a class.

Thanks,
Ralf.

link publish delete flag offensive edit

answered 2008-07-14 07:36:02 +0800

enixser gravatar image enixser
185 3

Another question: Where (or how) is the db.js file included? I did not find any reference in the source tree.

link publish delete flag offensive edit

answered 2008-07-14 10:02:26 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

Try this.

<script type="text/javascript">
zkDtbox._invalid = function (d, begin, end) {
    return true;
}
</script>

link publish delete flag offensive edit

answered 2008-07-14 10:35:49 +0800

enixser gravatar image enixser
185 3

updated 2008-07-14 10:38:24 +0800

Hi Henri,

this does not work. IE says:

Error: 'zkDtbox' is undefined

And are you sure zkDtbox is the right class? In db.js it has no function _invalid. This is a function of zk.Cal.

Best regards,
Ralf.

link publish delete flag offensive edit

answered 2008-07-16 02:50:23 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

Please post to feature reqeust.

link publish delete flag offensive edit
Your reply
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: 2008-07-08 14:51:16 +0800

Seen: 195 times

Last updated: Jul 16 '08

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