Hello,
I want to help you, but I need some more information about what behavior you are looking for.
In the sample that you send me I'm able to enter value and apply it.
Thanks,
George
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.
Dear DevExpress Team,
Do you have an idea have it can be reached?
Thank you.
Hello Gaurav,
You can create a Style for the Editor and add an EventSetter for the ValueChanged event in order to be notified when the value is changed.
I think in this case it would be best to wait for the change to be implemented. There are several aspects that would be difficult for you to work around. First, you don't want the Value of the editor to be changed but you do want the OriginalValue of the editor to be changed. The editor would have initialized that when it entered edit mode. Second, the end user may have typed in a partial value that is not parseable into a value so you would want the editor to keep that text the user entered and the caret/selection should remain intact.
What a coincidence! I am trying to do the exact same thing and posted a question yesterday on this forum. You should check out Stefan's answer and it may be helpful to you >> http://es.infragistics.com/community/forums/p/80441/405781.aspx#405781
I looked at Stefan's solution and it is very "close" to what I need. You don't need to subscribe to EditModeStarting or EditModeEnding event but instead should have a callback on DataValueChanged event (you need to set DataValueChangedNotificationsActive to "True" on FieldSettings object). Within this callback you will get a reference to DataValueChangedEventArgs object as an argument which will further provide references to the Field, Record, ValueHistory (holds previous historical values of that cell) and CellValuePresenter of the cell which got changed by the external ticking source.
PseudoCode >>>>
def dataValueChangedCallBack(senderObj, e):
# make sure the cell which got changed by an external source is the one which you are editing right now
if e.CellValuePresenter and e.CellValuePresenter.IsEditable and e.CellValuePresenter.IsInEditMode: ## CASE I
e.Record.Cells[e.Field.Name] = you_need_to_set_the_value_which_was_entered_by_the_user
else: ## CASE II
e.Record.Cells[e.Field.Name] = set_the_most_recent_value_from_ValueHistory_object
CASE II should be trivial. You have to set the DataValueChangedHistoryLimit to a suitable number on the FieldSettings object. Then you can get the historical data which is in the form of a Stack. Just get the top of stack (index=0) and set that to the cell.
CASE I is tricky. We somehow need to get the value which was recently entered by the user but it has not been committed yet since the user is still in EditMode. I have spent a LOT of time today trying to find an efficient way to find this uncommitted value from within the DataValueChanged callback but have been unsuccessful so far. I did find an inefficient way though ...we can subscribe to another event - "CellChanged" and then save the value entered by user in some form of a map (Key being the field/cell object which was modified by the user and Value being the new value which he entered) temporarily which can then be used inside the DataValueChanged callback.
Perhaps Stefan or someone in Infragistics dev team can point out an efficient way to get the value from within DataValueChanged callback. That would help in solving my problem too!
Hi ktokarieva,
I've discussed this a bit with our developers and they saw it necessary to log a development issue for this. Keeping the cell value from changing while the cell remains in edit mode when the underlying data item has changed isn't something that can be done at the moment because the grid manually updates the editor's value directly after the data changes. Our engineers will need to adjust this behavior internally.
I've opened up a private case for you and linked it to the development issue so that you may be notified when a fix or other resolution is available. The case number is CAS-116516-M3Q4Z1. The development issue ID is 143570.
You can find the case here: https://es.infragistics.com/my-account/support-activity
Hi,
I need first solution(1. Write an editor that works in the way you are expecting (not recomended)) but I have not an idea how it can be implemented.
How to distinguish that the user has entered a value into editor or value has been updated from DataContext?
Could you, please, provide an example?