Set Value of RadDatePicker in Widget Designer
I am trying to set the value of a RadDatePicker placed on the Designer of a Sitefinity Widget.
in the designer JS file I am doing the following:
jQuery(this.get_startdate()).set_selectedDate(new Date(controlData.StartDate));
But I am getting 'Undefinied is not a function.
How can I set the value of a RadDatePicker from the Designer's js file? Any Suggestions?
Thanks'
Hello Joe,
In order to achieve your need, you should add your component property in the GetScriptDescriptors() method inside your designer's C# class:
descriptor.AddComponentProperty(
"startdate"
,
this
.StartDate.ClientID);
this
.get_startdate().set_selectedDate(
new
Date(controlData.StartDate));
Hi Svetoslav,
Thanks for the heads up. The issue is that I was using AddElementProperty instead of AddComponentProperty.
Now the Date is displayed in the Designer of the Widget.
But got another issue now. When I hit Save in the Designer of the Widget Nothing happens and I get a js error.
Uncaught TypeError: Cannot read property 'toLowerCase' of undefined localhost:20593/ScriptResource.axd?d=ut6cYKafol9wWGp3sTJjPxiVlWuTuFB2b62RJz…S-GTV-MtnHQGQQj9K-xUrwFMXcgmgypJx-RgE6nsI_CAchXqC9vdd3Ido4ce0&t=43433ab4:2
When I changed it back to AddElementProperty in C# the error vanished
What do you think the issue is?
Thanks
Hello Joe,
You have to use "AddComponentProperty".
In order to get the value on click Save in the designer you can use:
var
selector = jQuery(
this
.get_startDateSelector())[0];
controlData.StartDate = selector.get_selectedDate().toDateString();
var
startDateString = controlData.StartDate;
var
startDateDate =
new
Date(startDateString);
if
(startDateDate)
jQuery(
this
.get_startDateSelector())[0].set_selectedDate(startDateDate);
Hi Svetoslav,
Works fine now, thanks for the help!
Regrads,
Joseph