Set Value of RadDatePicker in Widget Designer - General Discussions - General Discussions - Progress Community
 General Discussions

Set Value of RadDatePicker in Widget Designer

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

    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
     
  • 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

  • Hi Svetoslav,

    Works fine now, thanks for the help!

    Regrads,

    Joseph

  • 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