RowEditEnded or CellEditEnded are not fired on DatePicker inside GridViewDataColumn

9 posts, 0 answers
  1. Michael
    Michael avatar
    41 posts
    Member since:
    Oct 2010

    Posted 24 Jul 2013 Link to this post

    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>

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 24 Jul 2013 Link to this post

    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 >>
  3. DevCraft banner
  4. Michael
    Michael avatar
    41 posts
    Member since:
    Oct 2010

    Posted 24 Jul 2013 Link to this post

    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>
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 25 Jul 2013 Link to this post

    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 >>
  6. Michael
    Michael avatar
    41 posts
    Member since:
    Oct 2010

    Posted 08 Aug 2013 Link to this post

    Hi, 

    Thank you, that works.  I didn't realize that if I am creating a template, I need also define DataMemberBinding property. 
  7. Robert
    Robert avatar
    271 posts
    Member since:
    Mar 2011

    Posted 13 Jan 2014 Link to this post

    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
  8. Robert
    Robert avatar
    271 posts
    Member since:
    Mar 2011

    Posted 13 Jan 2014 Link to this post

    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.
  9. Robert
    Robert avatar
    271 posts
    Member since:
    Mar 2011

    Posted 13 Jan 2014 Link to this post

    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;
    }
  10. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 14 Jan 2014 Link to this post

    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 >>
Back to Top
DevCraft banner