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::

        ItemsSource="{Binding Loans}"
        IsBusy="{Binding AreLoansBusy}"
        CanUserSelect="{Binding CanUserSelectLoans}"
        SelectedItem="{Binding SelectedLoan, Mode=TwoWay}"
        IsReadOnly="{Binding UserHasProjectRole, Converter={StaticResource NegationConverter}}"
        CanUserInsertRows="{Binding UserHasProjectRole}"
        Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
                Header="Loan Type"
                DataMemberBinding="{Binding LoanTypeId}"
                ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.LoanTypes}"
                Width="Auto" />
                Header="Application Amount"
                DataMemberBinding="{Binding ApplicationAmount, StringFormat=c2}"
                Width="Auto" />
                Header="Total Project Costs"
                DataMemberBinding="{Binding TotalProjectCosts, StringFormat=c2}"
                Width="Auto" />
                Header="Eligible Project Costs"
                DataMemberBinding="{Binding EligibleProjectCosts, StringFormat=c2}"
                Width="Auto" />
                Header="Interest Rate"
                DataMemberBinding="{Binding InterestRate, StringFormat='{}{0}%'}"
                Width="Auto" />
                DataMemberBinding="{Binding Indenture}"
                Width="Auto" />
                Header="EFC Bond Series"
                DataMemberBinding="{Binding EfcBondSeries}"
                Width="Auto" />
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding LastUpdatedBy}" />
                            <TextBlock Text="{Binding LastUpdatedDate, StringFormat=g}" Margin="5 0 0 0" />
            <i:EventTrigger EventName="RowEditEnded">
            Command="{Binding LoanRowEditEndedCommand}"
            CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
            <i:EventTrigger EventName="Deleting">
            Command="{Binding LoanRowDeletingCommand}"
            CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
            <i:EventTrigger EventName="RowValidating">
            Command="{Binding LoanRowValidatingCommand}"
            CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />

    The bound data source:

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

  2. Answer
    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?

    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