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

RowEditEnded or CellEditEnded are not fired on DatePicker inside GridViewDataColumn

8 Answers 292 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 24 Jul 2013, 02:32 PM
Hi there,

I have a RadGridView with GridViewDataColumn which contains radDatePicker.  When date is changed inside the date picker, the RowEditEnded or CellEditEnded are not fired up. 

Here is piece of my code. 
<telerik:RadGridView  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" AutoGenerateColumns="False"     ShowGroupPanel="False" BorderThickness="0" ColumnWidth="*"   ItemsSource="{Binding Path=Downtimes}"  CellEditEnded="RadGridView_CellEditEnded" RowEditEnded="RadGridView_RowEditEnded" >                                              
                            <telerik:RadGridView.Columns>                               
                                <telerik:GridViewDataColumn Header="Date" Width="100">
                                    <telerik:GridViewDataColumn.CellTemplate>
                                        <DataTemplate>
                                            <telerik:RadDatePicker SelectedValue="{Binding Path=Date, Mode=TwoWay}"/>
                                        </DataTemplate>                                       
                                    </telerik:GridViewDataColumn.CellTemplate>
                                    <telerik:GridViewDataColumn.CellEditTemplate>
                                        <DataTemplate>
                                            <telerik:RadDatePicker SelectedValue="{Binding Path=Date, Mode=TwoWay}" />
                                        </DataTemplate>
                                    </telerik:GridViewDataColumn.CellEditTemplate>
                                </telerik:GridViewDataColumn>

8 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 24 Jul 2013, 04:12 PM
Hi,

The RowEditEnded and CellEditEnded events will be raised after a cell was set into edit mode and then its edit has been committed.

In your case you have redefined the CellTemplate, so I guess that you never go into edit mode for the GridView, you just edit the control inside the CellTemplate. If you leave just the CellEditTemplate (in your definition), then those events will be raised once you commit the edit (when the cell in edit mode loses focus).

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Michael
Top achievements
Rank 1
answered on 24 Jul 2013, 04:45 PM
Hi,

Thank you for quick reply. If I am understanding you correctly, you are saying to remove GridViewDataColumn.CellTemplate section  like code bellow?  In this case there is nothing showing up in the column until I double click on it.
<telerik:GridViewDataColumn Header="Date" Width="100">
    <telerik:GridViewDataColumn.CellEditTemplate>
        <DataTemplate>
            <telerik:RadDatePicker SelectedValue="{Binding Path=Date, Mode=TwoWay}"/>
        </DataTemplate>
    </telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>
0
Dimitrina
Telerik team
answered on 25 Jul 2013, 07:25 AM
Hello,

You should define DataMemberBinding for the column:

<telerik:GridViewDataColumn Header="Date" DataMemberBinding="{Binding Date}" Width="100">
...

How does this work?
 

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Michael
Top achievements
Rank 1
answered on 08 Aug 2013, 08:01 PM
Hi, 

Thank you, that works.  I didn't realize that if I am creating a template, I need also define DataMemberBinding property. 
0
Robert
Top achievements
Rank 1
answered on 13 Jan 2014, 12:28 PM
Hi,

Thanks for this solution, it works well.

One problem I'm having is that the RowEditEnded event is being fired when a selection is made with RadDatePicker. However, just because a date from the DatePicker has been selected, it doesn't mean that I have finished editing the row. Selecting the DatePick item causes the row to exit edit mode.

Is there a way to keep the row in edit mode and prevent the RowEditEnded event from being fired when a selection is made in the DatePicker?

Many thanks,

Rob
0
Robert
Top achievements
Rank 1
answered on 13 Jan 2014, 01:11 PM
I found that I can implement this:

this.gridDespatchDetails.ActionOnLostFocus = ActionOnLostFocus.None


Original Forum Post: http://www.telerik.com/community/forums/silverlight/gridview/keeping-cell-in-edit-mode.aspx

However, I'm not sure which events I can tie it to to set ActionOnLostFocus.None & ActionOnLostFocus.CommitEdit.
0
Robert
Top achievements
Rank 1
answered on 13 Jan 2014, 02:29 PM
Ok, assigning the ActionOnLostFocus to the RadDatePicker DropDownOpen & DropDownClosed Events seems to work.


<telerik:GridViewDataColumn Header="Date" DataMemberBinding="{Binding Date, StringFormat=d}">
    <telerik:GridViewDataColumn.CellEditTemplate>
        <DataTemplate>
            <telerik:RadDatePicker SelectedValue="{Binding Path=Date, Mode=TwoWay}"
                                   DropDownOpened="RadDatePicker_DropDownOpened"
                                   DropDownClosed="RadDatePicker_DropDownClosed" />
        </DataTemplate>
    </telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>



private void RadDatePicker_DropDownClosed(object sender, RoutedEventArgs e)
{
    if (this.gridDespatchDetails != null)
    {
        //Send Focus Back To GridView
        this.gridDespatchDetails.Focus();
        //Enable CommitEdit on GridView Lost Focus
        this.gridDespatchDetails.ActionOnLostFocus = ActionOnLostFocus.CommitEdit;
    }
     
}
 
private void RadDatePicker_DropDownOpened(object sender, RoutedEventArgs e)
{
    if(this.gridDespatchDetails != null)
        //Enable CommitEdit on GridView Lost Focus
        this.gridDespatchDetails.ActionOnLostFocus = ActionOnLostFocus.None;
}
0
Dimitrina
Telerik team
answered on 14 Jan 2014, 03:49 PM
Hi,

It seems you managed to find a solution. Let me know if any additional questions arise.

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Michael
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Michael
Top achievements
Rank 1
Robert
Top achievements
Rank 1
Share this question
or