I am having a tough time setting the dates that are selected in a RadCalendar. I have been researching this, and from what I see the only way is to fill the SelectedDates properrty. The RadCalendar is contained in a UserControl that is embedded in a RadPanelBar->RadPane object.
This is an MVC app with no code behind and is using a MasterPage.
I am filliing a ViewData[] member with an array of RadDates prior to showing the View. So everything has to be done using JavaScript.
I am unable to get the instance of RadCalendar as a "RadCalendar". Meaning in the OnLoad I get an object by it's ID but when I address the SelectedDates property I get the "SelectedDates" is not a known property", or "Undefined" message.
I can get the data using a JavaScript enabled, Ajax Enabled web service, or I can use a JSON result from the controller. But again, when I try to assign the array of RadDates to the Calendar object it fails.
So my questions are:
How do you get the instance of the Calendar object as RadCalendar?
How do you set the selected dates?
Any help or examples would be great.
Thanks,
Reid
This is an MVC app with no code behind and is using a MasterPage.
I am filliing a ViewData[] member with an array of RadDates prior to showing the View. So everything has to be done using JavaScript.
I am unable to get the instance of RadCalendar as a "RadCalendar". Meaning in the OnLoad I get an object by it's ID but when I address the SelectedDates property I get the "SelectedDates" is not a known property", or "Undefined" message.
I can get the data using a JavaScript enabled, Ajax Enabled web service, or I can use a JSON result from the controller. But again, when I try to assign the array of RadDates to the Calendar object it fails.
function
getEventDatesFromController()
{
var
returnData = $.ajax(
{
type:
"POST"
,
url:
"/Events/GetRadEventDatesByDateRange"
,
data:
"startDate="
+
"1/1/2000"
+
"&endDate="
+
"1/1/2100"
,
success:
function
(result) {
var
xml;
debugger
if
(
typeof
data ==
"string"
) {
xml =
new
ActiveXObject(
"Microsoft.XMLDOM"
);
xml.async =
false
;
xml.loadXML(data);
}
else
{
xml = result;
returnData = result;
var
ctrlEventCalendar = <%= ctrlEventCalendar.ClientID %>;
ctrlEventCalendar.selectDates(returnData,
true
); <-- Fails!!!, so does the following
for
loop
for
(
var
i = 0; i < returnData.length; i++) {
ctrlEventCalendar.SelectDate(returnData[i],
true
);
}
}
if
(result.success) {
alert(
"Controller Called Successfully"
);
},
error:
function
(req, status, error) {
alert("Sorry! Problem calling Event Controller
}
});
return
returnData;
}
<
div
class
=
"box-leftEventCalendar"
>
<
telerik:RadCalendar
runat
=
"server"
ID
=
"ctrlEventCalendar"
Style
=
"margin: 6px auto 0"
EnableMultiSelect
=
"false"
>
</
telerik:RadCalendar
>
</
div
>
So my questions are:
How do you get the instance of the Calendar object as RadCalendar?
How do you set the selected dates?
Any help or examples would be great.
Thanks,
Reid