Newly Added Row Disappears after RowEditEnded

3 posts, 1 answers
  1. Greg
    Greg avatar
    35 posts
    Member since:
    Sep 2013

    Posted 01 Aug 2014 Link to this post

    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. Answer
    Yoan
    Admin
    Yoan avatar
    1212 posts

    Posted 04 Aug 2014 Link to this post

    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.
     
  3. Greg
    Greg avatar
    35 posts
    Member since:
    Sep 2013

    Posted 18 Dec 2014 Link to this post

    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.
Back to Top