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

[Solved] RowEditEnded does fire up. Missing something....

7 Answers 160 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
John
Top achievements
Rank 1
John asked on 25 Oct 2010, 11:17 PM
Hello,
I have one RadGridview as implemented below:
<telerik:RadGridView x:Name="dgScheduleEdit"
                     RowEditEnded="dgScheduleEdit_RowEditEnded"
                     AutoGenerateColumns="False"
                     Foreground="Black" Background="#FFE7F0FA"
                     HorizontalContentAlignment="Stretch"
                     VerticalContentAlignment="Stretch"
                     AlternateRowBackground="#FFD6E6F6"
                     AlternationCount="2" Width="auto" Height="auto"
                     AllowDrop="False" ShowGroupPanel="False"
                     RowIndicatorVisibility="Collapsed">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding CPSchedule_ID}" IsVisible="False" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Title}" Header="Milestone" IsReadOnly="True" MaxWidth="300" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Projected_date}" Header="Projected Date">
            <telerik:GridViewDataColumn.CellTemplate>
                <DataTemplate>
                    <telerik:RadDateTimePicker InputMode="DatePicker" SelectedValue="{Binding Projected_date, Mode=TwoWay}" DateTimeWatermarkContent="" DisplayDateStart="1/1/2000" />
                </DataTemplate>
            </telerik:GridViewDataColumn.CellTemplate>
        </telerik:GridViewDataColumn>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Expected_date}" Header="Expected Date">
            <telerik:GridViewDataColumn.CellTemplate>
                <DataTemplate>
                    <telerik:RadDateTimePicker InputMode="DatePicker" SelectedValue="{Binding Expected_date, Mode=TwoWay}" DateTimeWatermarkContent="" DisplayDateStart="1/1/2000" />
                </DataTemplate>
            </telerik:GridViewDataColumn.CellTemplate>                       
        </telerik:GridViewDataColumn>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Actual_date}" Header="Expected Date">
            <telerik:GridViewDataColumn.CellTemplate>
                <DataTemplate>
                    <telerik:RadDateTimePicker InputMode="DatePicker" SelectedValue="{Binding Actual_date, Mode=TwoWay}" DateTimeWatermarkContent="" />
                </DataTemplate>
            </telerik:GridViewDataColumn.CellTemplate>
        </telerik:GridViewDataColumn>
        <telerik:GridViewCheckBoxColumn DataMemberBinding="{Binding Is_required}" IsReadOnly="True" Header="Required" />
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

Here is the code-behind for that RowEditEnded:
private void dgScheduleEdit_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
{
    //Calling the function to save data to DB
}

The fact is that dgScheduleEdit_RowEditEnded does't get called when I change any datetimepicker control.
Am I missing something?
Thanks
John.

7 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 26 Oct 2010, 07:47 AM
Hi John,

The thing is that when setting the CellTemplate as dateTimePicker, the cell does not get into edit-mode, consequently not firing the CellEditEnded and RowEditEnded events. So, what you may try to do is to define the CellEditTemplate of those particular columns to be RadDateTimePicker. Another possibility may be to handle the SelectionChanged event of the dateTimePicker and implement your custom logic here.
 

All the best,
Maya
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
0
John
Top achievements
Rank 1
answered on 26 Oct 2010, 06:24 PM
Thanks for your reply, Maya.  It seems like I have to define  CellEditTemplate for the event to kick in. 
Do you have any sample code for SelectionChanged for DateTimePicker control? 

Once again, thanks for your guidance.
John.
0
Maya
Telerik team
answered on 27 Oct 2010, 07:48 AM
Hello John,

I am sending you a sample project illustrating both cases - setting the CellEditTemplate ->firing CellEditEnded and RowEditEnded and setting CellTemplate->firing SelectionChanged event.
I hope that helps.

Best wishes,
Maya
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
0
John
Top achievements
Rank 1
answered on 27 Oct 2010, 06:10 PM
Thanks, Maya, for your sample.  I downloaded and there are empty methods.   The solution itself has errors so I can't seem to compile to get a sense of it. 

Here is what I have in xaml file:
<telerik:RadGridView Grid.Row="0"
                     Name="clubsGrid"
                     ItemsSource="{Binding Clubs}"
                     AutoGenerateColumns="False"
                     RowEditEnded="clubsGrid_RowEditEnded"
                     CellEditEnded="clubsGrid_CellEditEnded"                                               
                     AllowDrop="False" ShowGroupPanel="False"
                     RowIndicatorVisibility="Collapsed"
                     Margin="5">
    <telerik:RadGridView.Columns>
        <telerik:GridViewToggleRowDetailsColumn/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Established}"
                                    Header="Established 1"
                                    DataFormatString="{}{0:yyyy}"/>
 
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Established}" Header="Est./SelectionChanged">
            <telerik:GridViewDataColumn.CellTemplate>
                <DataTemplate>
                    <telerik:RadDateTimePicker InputMode="DatePicker"
                                               SelectionChanged="RadDateTimePicker_SelectionChanged"
                                               SelectedValue="{Binding Established, Mode=TwoWay}"
                                               DateTimeWatermarkContent="" DisplayDateStart="1/1/2000" />
                </DataTemplate>
            </telerik:GridViewDataColumn.CellTemplate>
        </telerik:GridViewDataColumn>
 
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Established}" Header="Est./CellEdidTemplate">
            <telerik:GridViewDataColumn.CellEditTemplate>
                <DataTemplate>
                    <telerik:RadDateTimePicker InputMode="DatePicker"                                                    
                                               SelectedValue="{Binding Established, Mode=TwoWay}"
                                               DateTimeWatermarkContent="" DisplayDateStart="1/1/2000" />
                </DataTemplate>
            </telerik:GridViewDataColumn.CellEditTemplate>
        </telerik:GridViewDataColumn>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding StadiumCapacity}"
                                    Header="Stadium"
                                    DataFormatString="{}{0:N0}"/>
    </telerik:RadGridView.Columns>
</telerik:RadGridView>     

Here is the code-behind:
public partial class MainPage : UserControl
{
    public MainPage()
    {
        InitializeComponent();         
    }      
 
    private void clubsGrid_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
    {
 
    }
 
    private void clubsGrid_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e)
    {
 
    }
 
    private void RadDateTimePicker_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
    {
 
    }
 
 
}


What I would love to see is how to "wire" the _SelectionChanged with the _RowEditEnded methods.
Once again, thanks much.
J
0
Accepted
Maya
Telerik team
answered on 28 Oct 2010, 08:26 AM
Hi John,

I tested the sample project I had sent to you and there were no problems in running it. What are the errors you are getting ? Considering the empty events, my purpose was to demonstrate how to subscribe to them. You can implement inside any logic you require. The SelectionChanged event of the RadDateTimePicker is fired once a new value is chosen. The RowEditEnded event is fired after editing the values of a particular item.

All the best,
Maya
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
0
John
Top achievements
Rank 1
answered on 28 Oct 2010, 05:06 PM
Thanks Maya.
I see the point in your sample solution.  What I am looking for is how to call a RowEditEnded method inside the SelectionChanged method.  The reason for it is to capture the row values and call for the update logic to the database since the RowEditEnded method never gets call with CellTemplate.

Do you have any idea how?
Thanks and accept my appreciation.
J.
0
Maya
Telerik team
answered on 29 Oct 2010, 07:45 AM
Hello John,

There are a couple of options here depending on your exact scenario. In case you want to save the changes made, you may call the CommitEdit() method of RadGridView.  If you require to get the updated value inside this particular row, you may get the corresponding item.
Let me know what are your particular expectations, so that I could suggest any further.
 

Kind regards,
Maya
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
GridView
Asked by
John
Top achievements
Rank 1
Answers by
Maya
Telerik team
John
Top achievements
Rank 1
Share this question
or