New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial

Expression similar to SQL's "Select Group By" clause that is used by GridTableView to group items (GroupByExpressions. Expressions can be defined by assigning Expression property and/or managing the items in SelectFields or GroupByFields collections.

If you use Expression property to assign group by expression as string then the expression is parsed and SelectFields and GroupByFields are created. If the expression syntax is incorrect a GridGroupByException would be thrown. You can use GridGroupByField's properties to set expression's fields appearance format strings, etc. See Expression property for details about the expression syntax.

Definition

Namespace:Telerik.Web.UI

Assembly:Telerik.Web.UI.dll

Syntax:

C#
public class GridGroupByExpression : IStateManager

Inheritance: objectGridGroupByExpression

Implements: IStateManager

Inherited Members object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()object.GetType()object.MemberwiseClone()...

Constructors

C#
public GridGroupByExpression()

Constructs a new GroupByExpression from a grid GridColumn.

C#
[SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
public GridGroupByExpression(GridColumn column)
Parameters:columnGridColumn

the column (and its DataField respectively) that will be used for grouping Telerik RadGrid

If the column does not have a valid GroupByExpression string assigned this constructor will throw GridGroupByException. Column should be Groupable The following properties will be copied from the corresponding column's properties:

C#
public GridGroupByExpression(string expression)
Parameters:expressionstring

Fields

C#
public const string GroupByClause = "Group By"

Properties

String representation of the GroupBy expression.

C#
public string Expression { get; set; }

Expression syntax:

fieldname[ alias]|aggregate(fieldname)[ alias][, ...] Group By fieldname[ sort][, ...]

  • fieldname: the name of any field from the DataSource
  • alias: alas string. This cannot contain blanks or other reserved symbols like ',', '.' etc.
  • aggregate: any of - min, max, sum, count, last, first etc (the same as in GridAggregateFunction enumeration )
  • sort: asc or desc - the sort order of the grouped items
Example:
cs-api-definition
Country, City, count(Country) Items, ContactName Group By Country, City desc

GroupByFields

GridGroupByFieldList

Gets a collection of GridGroupByField objects that form the grouping clause. Standing on the right side of the "Group By" clause

C#
[Browsable(false)]
[PersistenceMode(PersistenceMode.InnerProperty)]
public GridGroupByFieldList GroupByFields { get; }

Gets the index of the expression if added in a GridGroupByExpressionCollection

C#
[Browsable(false)]
public int Index { get; }
Property Value:

integer, representing the index of the collection ni GridGroupByExpressionCollection.

SelectFields

GridGroupByFieldList

Gets a collection of SelectField objects (field names, aggregates etc.) that form the "Select" clause. Standing on the left side of the "Group By" clause.

C#
[Browsable(false)]
[PersistenceMode(PersistenceMode.InnerProperty)]
public GridGroupByFieldList SelectFields { get; }

Methods

Checks if the given expression contains same Group-By field as this one.

C#
public bool ContainsSameGroupByField(GridGroupByExpression expression)
Parameters:expressionGridGroupByExpression

Expression to check

Returns:

bool

true if the expression already contains this GroupByField, otherwise false.

Use this function to determine if two expressions seem to produce the same set of results

Copies the current GridGroupByExpression from another GridGroupByExpression.

C#
public void CopyFrom(GridGroupByExpression expression)
Parameters:expressionGridGroupByExpression

The GridGroupByExpression to be coppied from.

Compares the current expression against the expression set as parameter and check if both expressions contain field with the same name.

C#
public bool IsSame(GridGroupByExpression expression)
Parameters:expressionGridGroupByExpression

expression to check against this expression

Returns:

bool

true if both expressions contain field with the same name, otherwise false.

Calls GridGroupByExpression(expression)

C#
public static GridGroupByExpression Parse(string expression)
Parameters:expressionstringReturns:

GridGroupByExpression

The same as the Expression property

C#
public override string ToString()
Returns:

string

the string representation of the expression.

Overrides: object.ToString()