DataTable.RejectChanges fails with RowNotInTableException

2 posts, 0 answers
  1. Anton
    Anton avatar
    12 posts
    Member since:
    Sep 2012

    Posted 03 Jun 2013 Link to this post

    Steps to reproduce:
    1. Add to project telerik controls v2011.3.1220.40
    2. Create DataView and bind to grid:
               
    DataTable dt = new DataTable("test");
    for (int i = 0; i < 10; i++)
    {
        dt.Columns.Add("column" + i);
    }
    for (int i = 0; i < 10; i++)
    {
        var row = dt.NewRow();
        for (int j = 0; j < 10; j++)
        {
            row[j] = j + i;
        }
        dt.Rows.Add(row);
    }
    dt.AcceptChanges();
     
    Items = dt.AsDataView();

    <Grid>   
         <
    Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="253*" />
        </Grid.RowDefinitions>
        <Button Command="{Binding UndoAllChanges}" Content="Undo all changes" Margin="10" HorizontalAlignment="Left" Padding="5,2" />
        <telerik:RadGridView ItemsSource="{Binding Items}" CanUserInsertRows="True" ShowInsertRow="True" Grid.Row="1" />
    </Grid>


    3. Add Undo function:
    private ICommand _undoAllChanges;
    public ICommand UndoAllChanges
    {
        get
        {
            if (_undoAllChanges == null)
            {
                _undoAllChanges = new DelegateCommand(obj =>
                {
                    Items.Table.RejectChanges();
                    OnPropertyChanged("Items");
                });
            }
            return _undoAllChanges;
        }
    }
    4. To reproduce bug need to run application, sort by column1, add new item, set cell [ newRow, column1 ] to "1", click enter and then undo button.

    P.S. I can't upload zip file because it's not allowed.
  2. Yordanka
    Admin
    Yordanka avatar
    634 posts

    Posted 04 Jun 2013 Link to this post

    Hi Anton,

    Could you test your solution with Q1 2013 SP1 official version - 2013.1.0403? I've tried your code and I couldn't reproduce the reported exception.
     
    Regards,
    Yordanka
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top