This is a migrated thread and some comments may be shown as answers.

Highlight the today day

6 Answers 100 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Udi
Top achievements
Rank 1
Udi asked on 21 Oct 2010, 11:20 PM
Hello,

I have a RadDatePicker control with footer that contain 2 buttons.One named "Today" and second named "OK" 
1. How can i highlight the today day on the calendar when i click the button( with java script) ?
    I do not want to toggle the calendar when i click the "Today" button, only highlight the current day on the calendar.
2. When i click on the "OK" button i want to put the selected date value  in the textbox and  toggle the calendar.
3. If i click on any date in the calendar i do not want to toggle the calendar (only the "OK" button toggle the calendar).


I need it in client side (JS).

Thank you,
Oren

6 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 26 Oct 2010, 02:19 PM
Hi Oren,

I am sending you a simple example which demonstrates the desired functionality. Please check it out and let me know if it helps you.

Greetings,
Radoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Udi
Top achievements
Rank 1
answered on 26 Oct 2010, 05:28 PM
Hello Radoslav,

Thank you for your response.

I have examined your attach sample and it almost what i was looking for.
The today button works well,but when i click on any date on the calendar i need it highlighted and only when i click on "OK" it should be toggle.
The "OK" button works well (the calendar get toggle) but when i click on any date on the calendar it doesn't get highlight (The OnDateClick event prevent it).
I need it highlight but not toggle.The "OK" will set the date on the textbox and hides the popup.

Regards,
Oren
0
Accepted
Radoslav
Telerik team
answered on 27 Oct 2010, 11:06 AM
Hi Oren,

I am sending you the modified example. Please check it out and let me know if it helps you.

Kind regards,
Radoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Rayne
Top achievements
Rank 1
answered on 09 Mar 2011, 02:50 PM
This is what I was looking for, so thanks. But i do have one question...

My page has two datetimepickers that I'd like to use the Today function on. Is there anyway I can use the same js function but just pass the ClientID as a parameter so that both controls can use it?
0
Shinu
Top achievements
Rank 2
answered on 10 Mar 2011, 11:12 AM
Hello,


I had a scenario where I needed similar functionality for multiple datepickers. I tried following approach to get it working.

ASPX:
<telerik:RadDatePicker runat="server" ID="RadDatePicker1">
    <Calendar ID="Calendar1" runat="server">
        <FooterTemplate>
            <asp:Button runat="server" Text="Today" OnClientClick="todayButtonClick('1'); return false;"
                ID="Button1" />
            <asp:Button runat="server" Text="OK" OnClientClick="okButtonClick('1'); return false;"
                ID="Button2" />
        </FooterTemplate>
    </Calendar>
</telerik:RadDatePicker>
<br />
<telerik:RadDatePicker runat="server" ID="RadDatePicker2">
    <Calendar ID="Calendar2" runat="server">
        <FooterTemplate>
            <asp:Button runat="server" Text="Today" OnClientClick="todayButtonClick('2'); return false;"
                ID="Button1" />
            <asp:Button runat="server" Text="OK" OnClientClick="okButtonClick('2'); return false;"
                ID="Button2" />
        </FooterTemplate>
    </Calendar>
</telerik:RadDatePicker>


Client code:
<script type="text/javascript">
    var currentDate;
    function todayButtonClick(pickerID) {
        if (pickerID == 1) {
            var calendar = $find("<%=RadDatePicker1.ClientID  %>");
        }
        else {
            var calendar = $find("<%=RadDatePicker2.ClientID  %>");
        }
        currentDate = new Date();
        calendar._setCalendarDate(currentDate);
    }
 
    function okButtonClick(pickerID) {
        if (pickerID == 1) {
            var calendar = $find("<%=RadDatePicker1.ClientID  %>");
        }
        else {
            var calendar = $find("<%=RadDatePicker2.ClientID  %>");
        }
        calendar.set_selectedDate(currentDate);
        calendar.hidePopup();
    }
</script>

 
Best of luck.. :)

-Shinu.
0
Rayne
Top achievements
Rank 1
answered on 10 Mar 2011, 02:27 PM
Thanks! That's just what I needed.
Tags
Calendar
Asked by
Udi
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Udi
Top achievements
Rank 1
Rayne
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or