Breaking Change T802552
Visible to All Users

GridView - The new Columns.Add method overload uses model-based properties and lambda expressions to create cell bands

Previously, you should have used temporary variables and the Columns.AddRange method to create cell bands.

Example:

Given GridView model:

C#
public string Address { get; set; } public string Country { get; set; } public string City { get; set; } public string Street { get; set; }

Creation syntax:

Razor
settings.Columns.Add(m => m.Address, c => { c.Columns.AddRange( new GridViewColumn[] { settings.Columns.Add(m => m.Country), settings.Columns.Add(m => m.City), settings.Columns.Add(m => m.Street), } ); });

or

Razor
var c1 = settings.Columns.Add(m => m.Country); var c2 = settings.Columns.Add(m => m.City); var c3 = settings.Columns.Add(m => m.Street); settings.Columns.Add<string>(m => m.Address, c => { c.Columns.AddRange(new GridViewColumn[] { c1, c2, c3, } ); });

Starting with version 19.2, we've changed the Columns.Add method overload. You can now use model-based properties and lambda expressions to create cell bands:

Razor
settings.Columns.Add(m => m.Address, c => { c.Columns.Add(m => m.Country); c.Columns.Add(m => m.City); c.Columns.Add(m => m.Street); });

Old method declaration:

C#
public MVCxGridViewColumn<ValueType> Add<ValueType>(Expression<Func<RowType, ValueType>> expression, Action<MVCxGridViewColumn> method)

New method declaration:

C#
public MVCxGridViewColumn<RowType> Add<ValueType>(Expression<Func<RowType, ValueType>> expression, Action<MVCxGridViewColumn<RowType>> method)

This change may affect your application.

Note: This breaking change relates only to scenarios where you use the Columns.Add method overload that accepts an action as a parameter.

For example, modify your code in the following manner and use a GridView’s mode type or the „var“ keyword if you store the Columns.Add method's result as a variable of the MVCxGridViewColumn<T> type:

Original code:

Razor
MVCxGridViewColumn<string> addressColumn = settings.Columns.Add(m => m.Address, c => { c.Caption = "Address"; });

Use GridView's mode type:

Razor
MVCxGridViewColumn<Person> addressColumn = settings.Columns.Add(m => m.Address, c => { c.Caption = "Address"; });

Use the "var" keyword:

Razor
var addressColumn = settings.Columns.Add(m => m.Address);

Additionally, in v19.2 use the following syntax …

Razor
var cAdress = settings.Columns.Add(m => m.CustomerAddress, c => { c.Caption = "Address"; }); cAdress.Columns.Add(m => m.CustomerAddress.Country); cAdress.Columns.Add(m => m.CustomerAddress.City); cAdress.Columns.Add(m => m.CustomerAddress.Street);

… if your model class contains complex properties and you rely on complex properties‘ types while using the Columns.Add method:

C#
public class Customer { public Address CustomerAddress { get; set; } } public class Address { public string Country { get; set; } public string City { get; set; } public string Street { get; set; } }

Razor
var cAdress = settings.Columns.Add(m => m.CustomerAddress, c => { c.Caption = "Address"; }); cAdress.Columns.Add(m => m.Country); cAdress.Columns.Add(m => m.City); cAdress.Columns.Add(m => m.Street);

This change may also affect your code if you cast a method parameter and/or the result of this method to MVCxGridViewColumn<T>.

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.