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

Show Hide Calendar for HTML

2 Answers 267 Views
Calendar for HTML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Shashank
Top achievements
Rank 1
Shashank asked on 13 Apr 2014, 12:59 PM
Hi team,

I want that on page load my calender control is closed and on a button click it should get open and allow me to select date and on selection the control should again get closed populating a textbox with the selected date.

I have achieved this in your XAML control, but i am not able to succeed here.

Looking forward for your help.

Thanks,
-Shashank



2 Answers, 1 is accepted

Sort by
0
Martin Yankov
Telerik team
answered on 14 Apr 2014, 10:50 AM
Hello Shashank,

Here is an example solution to your scenario:
  1. Add the Calendar control inside a FlyOut.
  2. On button click, show the FlyOut with the Calendar control.
  3. On Calendar change, save the selected value in a text input and hide the FlyOut.

Below you can see a code sample for reference:

<input id="button" type="button" value="Choose a Date" />
<input id="date" type="text" />
<div id="flyOut" data-win-control="WinJS.UI.Flyout">
    <div id="calendar"></div>
</div>

Here is the code behind:
var button = document.getElementById("button"),
    input = document.getElementById("date"),
    flyOut = document.getElementById("flyOut"),
    calendar = new Telerik.UI.RadCalendar(document.getElementById("calendar"));
 
button.addEventListener("click", function () {
    flyOut.winControl.show(button);
});
 
calendar.addEventListener("change", function (e) {
    var calendarControl = e.target,
        value = calendarControl.value.toDateString();
 
    input.value = value;
    flyOut.winControl.hide();
});

You can also find an example project attached. Let me know if you need any further assistance.

Regards,
Martin Yankov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
alis
Top achievements
Rank 2
answered on 13 Oct 2014, 12:16 PM
The easiest way is data picker jQuery's. One line of code....done.
<script type="text/javascript">
$( "#datepicker" ).datepicker();
</script>
Tags
Calendar for HTML
Asked by
Shashank
Top achievements
Rank 1
Answers by
Martin Yankov
Telerik team
alis
Top achievements
Rank 2
Share this question
or