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

RadDatePicker SelectionChanged event ?

6 Answers 384 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
Marjeta Segrec
Top achievements
Rank 1
Marjeta Segrec asked on 30 Mar 2009, 06:44 PM
Hello.

How can stop SelectionChanged Event when Loading Page - is this bug ?
As you can see in code below the Handler for SelectionChanged is added after RadDatePicker1.SelectedDate is setted.

Partial Public Class Page  
    Inherits UserControl  
 
    Public Sub New()  
        InitializeComponent()  
 
        Me.RadDatePicker1.SelectedDate = Date.Now  
 
        AddHandler RadDatePicker1.SelectionChanged, AddressOf OnRadDatePickerSelectionChanged  
    End Sub  
 
    Private Sub OnRadDatePickerSelectionChanged(ByVal sender As Object, ByVal e As Telerik.Windows.Controls.SelectionChangedEventArgs)  
        MessageBox.Show("OnRadDatePickerSelectionChanged")  
    End Sub  
 
End Class 

Thanks for your answer.

6 Answers, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 31 Mar 2009, 09:21 AM
Hello Marjeta,

This indeed is not the expected behavior.

It is due to the fact that the SelectionChanged event arises not from the DatePicker itself but from the Calendar that is in its template (thus the DatePicker reuses a lot of functionality from the Calendar).

When the template is applied (on page loading) the calendar binds to the properties of the DatePicker, and the selection changed event is fired, initiated by the calendar.

Thank you for bringing our attention to this, I have updated your telerik points.

We will look into this, but I am not sure if the fix will make it in time for the SP1.

In the meantime, unfortunately I cannot offer a workaround for this.

I hope that this behavior will not be a show-stopper for you. If it is, please come back to us and we will offer suggestions for your particular scenario or send you a hotfix once it is ready.

Sincerely yours,
Miroslav
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Marjeta Segrec
Top achievements
Rank 1
answered on 31 Mar 2009, 06:15 PM
Hello.

This is the big problem for my application because when user edit record in page then this event is fired and produces the event like Data is changed - so user can not close the page without press the Save button for nothing.

I will appreciated if you can find temporary solution for this.

Thanks.
0
Miroslav
Telerik team
answered on 02 Apr 2009, 09:27 AM
Hello Marjeta,

Unfortunately I could not find a generic fix for the problem. I noticed that if the DatePicker is part of a ContentTemplate and only the DataContext is changed, the event will fire. For example this will happen if you have a TabControl with templated items. (Similarly a master-details view). What happens is that when the DataContext is changed the binding changes the value of the DatePicker and the selection event fires.

This is expected, since the value does actually change. Could you please ignore the first event after data context change?

Also, the event fires when the control is first loaded and is bound. But then also the value is actually changed. The problem really is that the event does not fire right away, but only after the control is loaded. Again, could you please ignore the first event after the control has loaded.

Note that the SelectionChanged event is a routed event and can be canceled at any point along its route. (I.e. if you handle the event at a parent level, you can cancel it before it reaches the business-logic handlers.)

Again, sorry that we could not come up with a solution quickly. We will look into the problem of the late event firing, but unfortunately the behavior when the DataContext is changed is expected. 

Sincerely yours,
Miroslav
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Marjeta Segrec
Top achievements
Rank 1
answered on 02 Apr 2009, 10:34 AM
Hello.

Thanks for your answer and efort. I will catch the first SelectionChanged event on Page load and ignore them.
0
Ian
Top achievements
Rank 1
answered on 02 Nov 2010, 05:11 AM
I am using 2010.2.812.1040 version of your control suite, and experiencing the same problems still. Any idea when is this going to be fixed? 
0
Kaloyan
Telerik team
answered on 05 Nov 2010, 08:23 AM
Hi Ian,

We have made some big changes regarding the Date/Time pickers. So as a first step you have to use the SelectedValue instead the SelectedDate property. Give it a try a feel free to inform us in case of problem appearing.

Sincerely yours,
Kaloyan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
DatePicker
Asked by
Marjeta Segrec
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Marjeta Segrec
Top achievements
Rank 1
Ian
Top achievements
Rank 1
Kaloyan
Telerik team
Share this question
or