Hi,
The xamDataGrid is a control to show/edit your data. It has the events to identify when is entering/exiting edit mode.
The logic for updating your data is not part of the control, so I'll need to see your code to propose good solution in your case.
Thanks,
George
Hi George.
Thanks for your answer. It works but not for my case.
In your case you use method UpdateCellValue to update value of cell(and then DataContext) from code behind.
But in my case DataContext of xamDataGrid updates from outside and I need to suppress update the value of ValueEditor when cell is in edit mode
Do you have a solution for my case?
Thank you.
I liked more Infragistics Team :)
If you want to suppress updating you may use the events:
EditModeStarted ="DataPresenterBase_OnEditModeStarted" EditModeEnded="DataPresenterBase_OnEditModeEnded"
private bool _stopUpdating = false; private void UpdateCellValue(object sender, EventArgs eventArgs) { if (_stopUpdating) { return; } ViewModel.Persons[0].Name = newValueTextBox.Text; } private void DataPresenterBase_OnEditModeStarted(object sender, EditModeStartedEventArgs e) { _stopUpdating = true; } private void DataPresenterBase_OnEditModeEnded(object sender, EditModeEndedEventArgs e) { _stopUpdating = false; }
Hope that helps,
Dear DevExpress Team,
Do you have an idea have it can be reached?
Thank George for your answer. I'll try to provide more details.
Use case:
1. User set cell in edit mode then enter new value and stay cell in edit mode.
2. Update source(binded property) from outside but stay cell in edit mode with user entered new value.
3. User can leave edit mode by:
- press Enter key to apply entered new value (and rewrite updated value from outside);
- press Escape key to revert entered new value and apply updated value from outside;
The test project "DiscardUpdateCellInEditMode" which I've attached contains window. Window contains xamDataGrid with one record and one column callled "Name". DataSource binds to collection called "Persons" of "Person" objets with single property "Name". "Persons" collection initialized by one "Person" instants(property "Name" was set to "Person name"). Also the window contains TextBox UI Element. Text from TextBox is set to Person's Name property every 5 sec.
So initialization data is following when we start test project:
1. The collection Persons contains one Person instant with Name = "Person name" => xamDataGrid cell value is also equal to "Person name".
2. TextBox.Text = "New Cell Value".
3. In 5 sec Person.Name will set to TextBox.Text("New Cell Value") => xamDataGrid cell value also will set to TextBox.Text("New Cell Value").
Current behavior of the test project:
1. User run application set cell in edit mode and enter new value "User Entered Value" and do not leave edit mode.
2. Cell will stay in edit mode BUT ENTERED VALUE("User Entered Value") WILL UPDATED BY "New Cell Value" in 5 sec.
I expected following behavior of the test project:
1. The same
2. Cell will stay in edit mode AND VALUE WILL STAY "User Entered Value" in 5 sec. The user can press Escape key to leave edit mode and apply value "New Cell Value" OR press Enter key to leave edit mode and apply "User Entered Value"(and set this value to Person.Name).
So the goal is "Supress update the value of ValueEditor when cell is in edit mode and source(in our case Person.Name) is updated outside".
Thank you in advice.