This is a migrated thread and some comments may be shown as answers.

RadDatePicker and custom attributes

1 Answer 232 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
Paul Evers
Top achievements
Rank 2
Paul Evers asked on 04 Apr 2016, 10:16 AM

I have a RadDatePicker where I have a custom attribute

<telerik:RadDatePicker ID="RadDatePicker_MinDate" runat="server" AutoPostBack="false" CssClass="InputDateField" variable="mindate">
    <ClientEvents OnPopupOpening="DatePickerOnFocus"
                           OnDateSelected="RadDatePicker_MinDate_DateSelected" />
    <DateInput runat="server"
          ClientEvents-OnFocus="DatePickerOnFocus">
    </DateInput>
</telerik:RadDatePicker>

The clientside function DatePickerOnFocus:

function DatePickerOnFocus(sender, eventArgs) {
        var id = sender.get_element().id + "_wrapper";
        var wrapper = $get(id);
        var var1 = wrapper.getAttribute("variable");
        .......
}

This works fine for the event OnPopupOpening.

For the event ClientEvents-OnFocus (of the DateInput) this doesn't work. I get a null value when reading the custom attribute.

How can I get the custom attribute in the event ClientEvents-OnFocus of the DateInput?

 

Paul

1 Answer, 1 is accepted

Sort by
0
Accepted
Viktor Tachev
Telerik team
answered on 04 Apr 2016, 11:15 AM
Hello Paul,

The behavior you are observing is expected. Note that the sender is different in the two events.

When the OnPopupOpening event is handled the sender represents the client-side object of RadDatePicker.

When the DateInput-ClientEvents-OnFocus event is handled the sender is actually a DateInput object.

In order to retrieve the custom attribute consistently you need to ensure that you get reference of the RadDatePicker element.

Try to use the modified code below and let me know how it works.


function DatePickerOnFocus(sender, args) {
    var id = sender.get_element().id.replace("_dateInput", "") + "_wrapper";
    var wrapper = $get(id);
    var var1 = wrapper.getAttribute("variable");
 
}


Regards,
Viktor Tachev
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
DatePicker
Asked by
Paul Evers
Top achievements
Rank 2
Answers by
Viktor Tachev
Telerik team
Share this question
or