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

Newly Added Row Disappears after RowEditEnded

2 Answers 362 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 01 Aug 2014, 05:22 PM
If I click the "Click here to add new item" row in my gridview, a new row appears as expected. However, as soon as I click anywhere other than on the new row (triggering RowEditEnded), the new row disappears from the gridview and the "Click here to add new item" row replaces it.

If I then save changes, the invisible row DOES save to the database and re-appears after a refresh. In other words, while the row disappears visually from the grid, it still exists in the datasource the grid binds to and is valid enough to save.

If I repeat the actions in the first paragraph 10 times and then save changes, 10 invisible rows will save to the database and reappear after a refresh.

What is going on here???

The gridview::

<telerik:RadGridView
    x:Name="LoanGrid"
    ItemsSource="{Binding Loans}"
    IsBusy="{Binding AreLoansBusy}"
    CanUserSelect="{Binding CanUserSelectLoans}"
    SelectedItem="{Binding SelectedLoan, Mode=TwoWay}"
    Margin="10,-6,10,10"
    GroupRenderMode="Flat"
    IsReadOnly="{Binding UserHasProjectRole, Converter={StaticResource NegationConverter}}"
    ColumnWidth="*"
    CanUserInsertRows="{Binding UserHasProjectRole}"
    SelectionMode="Single"
    NewRowPosition="Bottom"
    AutoGenerateColumns="False"
    IsSynchronizedWithCurrentItem="True"
    ShowGroupPanel="False"
    IsFilteringAllowed="False"
    ValidatesOnDataErrors="InEditMode"
    ActionOnLostFocus="CommitEdit"
    Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
 
    <telerik:RadGridView.Columns>
        <telerik:GridViewComboBoxColumn
            Header="Loan Type"
            IsReadOnly="False"
            DataMemberBinding="{Binding LoanTypeId}"
            SelectedValueMemberPath="Id"
            DisplayMemberPath="Description"
            ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.LoanTypes}"
            Width="Auto" />
        <telerik:GridViewDataColumn
            UniqueName="ApplicationAmount"
            Header="Application Amount"
            DataMemberBinding="{Binding ApplicationAmount, StringFormat=c2}"
            TextAlignment="Right"
            Width="Auto" />
        <telerik:GridViewDataColumn
            Header="Total Project Costs"
            DataMemberBinding="{Binding TotalProjectCosts, StringFormat=c2}"
            TextAlignment="Right"
            Width="Auto" />
        <telerik:GridViewDataColumn
            Header="Eligible Project Costs"
            DataMemberBinding="{Binding EligibleProjectCosts, StringFormat=c2}"
            TextAlignment="Right"
            Width="Auto" />
        <telerik:GridViewDataColumn
            Header="Interest Rate"
            DataMemberBinding="{Binding InterestRate, StringFormat='{}{0}%'}"
            TextAlignment="Right"
            Width="Auto" />
        <telerik:GridViewDataColumn
            Header="Indenture"
            DataMemberBinding="{Binding Indenture}"
            Width="Auto" />
        <telerik:GridViewDataColumn
            Header="EFC Bond Series"
            DataMemberBinding="{Binding EfcBondSeries}"
            Width="Auto" />
        <telerik:GridViewDataColumn
            Header="Auditing"
            IsReadOnly="True"
            Width="Auto">
            <telerik:GridViewDataColumn.CellTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding LastUpdatedBy}" />
                        <TextBlock Text="{Binding LastUpdatedDate, StringFormat=g}" Margin="5 0 0 0" />
                    </StackPanel>
                </DataTemplate>
            </telerik:GridViewDataColumn.CellTemplate>
        </telerik:GridViewDataColumn>
    </telerik:RadGridView.Columns>
 
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="RowEditEnded">
            <infrastructure:InvokeDelegateCommandAction
        Command="{Binding LoanRowEditEndedCommand}"
        CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
        </i:EventTrigger>
        <i:EventTrigger EventName="Deleting">
            <infrastructure:InvokeDelegateCommandAction
        Command="{Binding LoanRowDeletingCommand}"
        CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
        </i:EventTrigger>
        <i:EventTrigger EventName="RowValidating">
            <infrastructure:InvokeDelegateCommandAction
        Command="{Binding LoanRowValidatingCommand}"
        CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
</telerik:RadGridView>

The bound data source:

public QueryableDataServiceCollectionView<ProjectPhaseLoan> Loans { get; private set; }

2 Answers, 1 is accepted

Sort by
0
Accepted
Yoan
Telerik team
answered on 04 Aug 2014, 11:04 AM
Hello Greg,

Unfortunately with the supplied information I cannot figure out what is going on. Could you please try to isolate the problem you have in a demo project which we could debug locally? 

As a side note - could you try removing the EventTriggers and let me know about the result?

Regards,
Yoan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Greg
Top achievements
Rank 1
answered on 18 Dec 2014, 05:20 PM
I finally got back to this issue.

It turned out to be caused by the grid being filtered on a parent id and my code not setting that parent id. So as soon as focus left the row, it was filtered out.
Tags
GridView
Asked by
Greg
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Greg
Top achievements
Rank 1
Share this question
or