Hi,
I am using RadDatePicker and I want to make whole week selectable. When user click on any date then whole week row will be selected and input field will be filled with Monday's date. Also I can set default week by date.
In my page, depending on some settings (SomeSettings), I want just the week days be selected (weekends be excluded) when the user clicks on one of the week numbers. Below you can find my solution. As I am calling $(".RadAjax").hide(); currently to solve the AutoPostBack problem after calling sender.selectDate() function, I was wondering if anyone can provide a better solution:
<
div
id
=
"uxSmallCalendarPanel"
style
=
"width: 220px;"
runat
=
"server"
>
<
Telerik:RadCalendar
DayCellToolTipFormat
=
""
EnableNavigationAnimation
=
"true"
Style
=
"text-align: center;"
AutoPostBack
=
"true
CalendarTableStyle-BorderWidth
=
"0"
Width="100%" EnableMultiSelect="true" BorderStyle="None" runat="server" ID="uxCalendar" SkinID="imcrm" CultureInfo="" >
<
ClientEvents
OnRowHeaderClick
=
"confirmRowSelection"
/>
</
Telerik:RadCalendar
>
</
div
>
<
Telerik:RadAjaxManagerProxy
runat
=
"server"
ID
=
"uxAjaxManager"
>
<
AjaxSettings
>
<
Telerik:AjaxSetting
AjaxControlID
=
"uxSmallCalendarPanel"
>
<
UpdatedControls
>
<
Telerik:AjaxUpdatedControl
ControlID
=
"uxSmallCalendarPanel"
LoadingPanelID
=
"uxSmallLoadingPanel"
/>
</
UpdatedControls
>
</
Telerik:AjaxSetting
>
</
AjaxSettings
>
</
Telerik:RadAjaxManagerProxy
>
<
script
type
=
"text/javascript"
>
function confirmRowSelection(sender, eventArgs)
{
eventArgs.set_cancel(true);
var year = sender.get_focusedDate()[0];
var weekNumber = eventArgs.get_domElement().innerHTML;
var firstDayOfSelectedWeek = new Date(year, 0, (weekNumber - 1) * 7);
for (var i = 0; i < (SomeSettings ? 5 : 7); i++)
{
var selectedDate = new Date(firstDayOfSelectedWeek);
selectedDate.setDate(selectedDate.getDate() + i);
sender.selectDate([selectedDate.getFullYear(), selectedDate.getMonth() + 1, selectedDate.getDate()]);
}
$(".RadAjax").hide();
</
script
>