WPF CellEditing issue - reload datagrid rows

408 views Asked by At

I have datagrid and one panel. When I click on any row, all data should be appeared on that panel. And when I edit cell and after editing if I click another cell of same row, panel should be updated immediately. My datagrid is bound through item source (data table), so if I make any change to grid (add/delete/edit) my item source is updated and as per item source Panel is updated.

To achieve cell edit thing I use following code and it's working.

void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
    {
        if (!isManualEditCommit)
        {
            isManualEditCommit = true;
            DataGrid grid = (DataGrid)sender;
            grid.CommitEdit(DataGridEditingUnit.Row, true);
            isManualEditCommit = false;           
        }
    }

Issue: Only issue is when this line gets called (grid.CommitEdit), it basically loading all rows again.and if datatable is really big than it takes few sec to load all rows. If I don't commit grid then my changes of datagrid appears on panel after I click on another row. I want to achieve it when i click on another cell of same row without loading rows again.

Here is Image

enter image description here

Pls help

Thanks

1

There are 1 answers

0
GameAlchemist On

this is a common pitfall of the DataGrid : the commit logic. The solution i found (it was booleans, not numbers) was to make my own custom DataGridColumn, with my bindings triggers set on PropertyChanged, to have the content updated at once and not only on commit. Surely this is a little work, but DataGrid standards column won't allow you to change that commit logic.