Set Value of RadDatePicker in Widget Designer

Posted by Community Admin on 03-Aug-2018 08:44

Set Value of RadDatePicker in Widget Designer

All Replies

Posted by Community Admin on 22-May-2014 00:00

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'

Posted by Community Admin on 27-May-2014 00:00

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);

and not to wrap it in jQuery, just call:
this.get_startdate().set_selectedDate(new Date(controlData.StartDate));

Regards,
Svetoslav Manchev
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 30-May-2014 00:00

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

Posted by Community Admin on 31-May-2014 00:00

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();

and to set by:
var startDateString = controlData.StartDate;
var startDateDate = new Date(startDateString);
if (startDateDate)
    jQuery(this.get_startDateSelector())[0].set_selectedDate(startDateDate);
 

Regards,
Svetoslav Manchev
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 31-May-2014 00:00

Hi Svetoslav,

Works fine now, thanks for the help!

Regrads,

Joseph

This thread is closed