Breaking Change T865261
Visible to All Users

Data Grid – For combo box columns bound to a collection of custom objects, the RowUpdating(Async) and RowInserting(Async) event handlers now accept the entire selected item instead of the selected item's value

The Data Grid's edit form displays a combo box editor for a DxDataGridComboBoxColumn. When you bind this column to a collection of custom objects, the combo box editor is populated with items that correspond to these custom objects. The ValueFieldName property specifies a custom object's field, which provides item values. These item values match cell values in the Data Grid's data source.

Razor
<DxDataGrid Data="@GridDataSource" RowUpdating="@((dataItem, newValues) => OnRowUpdating(dataItem, newValues))" ...> <DxDataGridComboBoxColumn Field="@nameof(GridDataSource.RegionID)" Data="@ShipRegions" ValueFieldName="@nameof(ShipRegion.ID)" ...> </DxDataGridComboBoxColumn> ... </DxDataGrid> @code { IEnumerable<GridDataItem> GridDataSource; IEnumerable<ShipRegion> ShipRegions; ... void OnRowUpdating(GridDataItem dataItem, Dictionary<string, object> newValue) { MyDataService.Update(dataItem, newValue); } }

In previous versions, the RowUpdating, RowUpdatingAsync, RowInserting and RowInsertingAsync event handlers contained a value of the combo box's selected item in the dictionary of new values.

In v19.2, these event handlers contain the combo box's selected item (the entire custom object). This allows you not only to operate with the selected item's value, but access values of all its fields.

If you handled one of these events, update your code that posts changes to the data source. You should now access an item value from the custom object as shown in the code snippet below.

Old

C#
void Update(GridDataItem dataItem, IDictionary<string, object> newValue) { foreach (var field in newValue.Keys) { switch (field) { ... case nameof(dataItem.RegionID): dataItem.RegionID = (string)newValue[field]; break; } } }

New

C#
void Update(GridDataItem dataItem, IDictionary<string, object> newValue) { foreach (var field in newValue.Keys) { switch (field) { ... case nameof(dataItem.RegionID): dataItem.RegionID = ((ShipRegion)newValue[field]).ID; break; } } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.