0

how to display week selected in calendar [closed]

asked 2014-02-24 06:26:09 +0800

anujtarun gravatar image anujtarun flag of India
205 6

updated 2014-04-01 11:54:18 +0800

how can display week selected on calendar control,

for example when click on 23 Feb 2014 then complete week should be selected that is from 23-Feb 2014 to 01-March-2014

its not working in zk version 7, please check the link for example http://zkfiddle.org/sample/nl2088/3-Another-new-ZK-fiddle

delete flag offensive retag edit

The question has been closed for the following reason "duplicate question" by sitansu
close date 2014-04-04 19:00:08

Comments

its not working in zk version 7, please check the link for example http://zkfiddle.org/sample/nl2088/3-Another-new-ZK-fiddle

anujtarun ( 2014-04-01 11:52:09 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted
3

answered 2014-02-24 06:57:15 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

please refer to the related article at stackoverflow http://stackoverflow.com/questions/16190586/how-to-selected-week-in-calendar-in-zk

link publish delete flag offensive edit

Comments

its not working in zk version 7, please check the link for example http://zkfiddle.org/sample/nl2088/3-Another-new-ZK-fiddle

anujtarun ( 2014-04-01 11:51:04 +0800 )edit

yes, because dom structure changed a lot since ZK7

benbai ( 2014-04-04 13:58:53 +0800 )edit
2

answered 2014-04-04 12:58:52 +0800

anujtarun gravatar image anujtarun flag of India
205 6

updated 2014-04-04 13:26:12 +0800

sitansu gravatar image sitansu
2254 13
http://java91.blogspot.in...

Please find the answer below this will work in zk version 7

<zk xmlns:w="client">
    <style>
        .custom-selected-node {
            background-color: #99FF99 !important;
        }
    </style>
    <vlayout>
        <label value="selected dates" />
        <textbox rows="7" id="tbx" width="300px" />
    </vlayout>
    <calendar id="cal" use="test.custom.component.WeekPicker">
        <attribute w:name="_markCal"><![CDATA[
            function (opts) {
                // clear old custom-selected-node
                jq('.custom-selected-node').each(function () {
                    jq(this).removeClass('custom-selected-node');
                });
                this.$_markCal(opts);
                if (this._view == 'day') {
                    // target: current focused date (td)
                    // parent: tr
                    var target = jq('.z-calendar-selected')[0],
                        parent = target.parentNode,
                        node = parent.firstChild,
                        beforeCnt = 0,
                        found;
                    // loop through each td
                    while (node) {
                        // add selected style
                        jq(node).addClass('custom-selected-node');
                        if (node == target) {
                            found = true;
                        } else if (!found) {
                            // count nodes before target
                            beforeCnt++;
                        }
                        node = node.nextSibling;
                    }
                    // fire event to server
                    this.fire('onCustomSelect', {bcnt: beforeCnt});
                }
            }
        ]]></attribute>
        <attribute name="onCustomSelect"><![CDATA[
            List dates = self.getSelectedDates();
            java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd / MM / yyyy");
            String value = "";
            for (int i = 0; i < dates.size(); i++) {
                value = value + sdf.format((Date)dates.get(i)) + "\n";
            }
            tbx.setValue(value);
        ]]></attribute>
    </calendar>
</zk>
link publish delete flag offensive edit

Question tools

Follow
2 followers

RSS

Stats

Asked: 2014-02-24 06:26:09 +0800

Seen: 19 times

Last updated: Apr 04 '14

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