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

Field which is part of each SelectFields and GroupByFields collection

Some of the GridGroupByField properties are meaningful only when present under specific collection - SelectFields or GroupByFields

Definition

Namespace:Telerik.Web.UI

Assembly:Telerik.Web.UI.dll

Syntax:

C#
public class GridGroupByField

Inheritance: objectGridGroupByField

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

Example:

csharp
Dim groupExpression As GridGroupByExpression = New GridGroupByExpression()

Dim groupByField As GridGroupByField = New GridGroupByField()

groupByField = New GridGroupByField()
groupByField.FieldName = "Received"
groupExpression.SelectFields.Add(groupByField)

groupByField = New GridGroupByField()
groupByField.FieldName = "Received"
groupExpression.GroupByFields.Add(groupByField)

RadGrid1.MasterTableView.GroupByExpressions.Add(groupExpression)
csharp
GridGroupByExpression groupExpression = new GridGroupByExpression();

GridGroupByField groupByField = new GridGroupByField();
groupByField = new GridGroupByField();
groupByField.FieldName = "Received";
groupExpression.SelectFields.Add(groupByField);

groupByField = new GridGroupByField();
groupByField.FieldName = "Received";
groupExpression.GroupByFields.Add(groupByField);

RadGrid1.MasterTableView.GroupByExpressions.Add(groupExpression);

Constructors

C#
public GridGroupByField()

Properties

Gets or sets aggregate function (from GridAggregateFunction enumeration values) that will be applied on the grouped data.

C#
public GridAggregateFunction Aggregate { get; set; }
Property Value:

Returns the result from currently used aggregate function. This property defaults to GridAggregateFunction.None

Meaningful only for fields in the SelectFields collection.

Example:
cs-api-definition
GridGroupByField gridGroupByField;

gridGroupByField = new GridGroupByField();
gridGroupByField.FieldName = "Freight";
gridGroupByField.HeaderText = "Total shipping cost is ";
gridGroupByField.Aggregate = GridAggregateFunction.Sum;
expression.SelectFields.Add( gridGroupByField );

Gets or sets a value representing a friendly name for the field used for forming the group by expression. This name will be displayed in each group header when grouping by the respective field.

C#
public string FieldAlias { get; set; }
Property Value:

String representing the friendly name shown

Use this property for setting the field text that will be displayed in the GridGroupHeaderItem. If this property is not set, the value of FieldName property will be used. Note that this property has a meaning only for GridGroupByField part of the SelectFields of GridGroupByExpression.

This property is useful in cases when:

  • you want to change the value displayed in group header (different than the default DataField column value)
    or
  • group by a template column and Telerik RadGrid cannot get the header text for that column.
Example:
cs-api-definition
GridGroupByField gridGroupByField;

//Add select fields (before the "Group By" clause)
gridGroupByField = new GridGroupByField();
gridGroupByField.FieldName = "EmployeeID";
gridGroupByField.FieldAlias = "EmployeeIdentificator";
expression.SelectFields.Add( gridGroupByField );

Gets or sets a string that represents the DataField column property that will be used to form the GroupByExpression.

C#
public string FieldName { get; set; }
Property Value:

String representing the DataField for the corresponding grouped column

Unless you have specified a FieldAlias, the value of this property will be used when Telerik RadGrid constructs the text for GridGroupHeaderItem. FieldName has a meaning both for SelectFields and GroupByFields of GroupByExpression.

Example:
cs-api-definition
GridGroupByField gridGroupByField;

//Add select fields (before the "Group By" clause)
gridGroupByField = new GridGroupByField();
gridGroupByField.FieldName = "EmployeeID";
gridGroupByField.HeaderText = "Employee";
expression.SelectFields.Add( gridGroupByField );

//Add a field for group-by (after the "Group By" clause)
gridGroupByField = new GridGroupByField();
gridGroupByField.FieldName = "EmployeeID";
expression.GroupByFields.Add( gridGroupByField );

Gets or sets the string that will be used to format the GridGroupByField part of the SelectFields collection.

C#
public string FormatString { get; set; }
Property Value:

String, formated by the GridGroupByField's FormatString property. It defaults to: "{0}".

Meaningful only for fields in the SelectFields collection.

When rendering RadGrid is using this expression to format field's value. It is mandatory that {0} parameter is specified in the string - it will be replaced with field's runtime value.

Example:
cs-api-definition
GridGroupByField gridGroupByField;

gridGroupByField = new GridGroupByField();
gridGroupByField.FieldName = "EmployeeID";
gridGroupByField.FormatString = "<strong>{0}</strong>";
expression.SelectFields.Add( gridGroupByField );

Gets or sets the expression that will be displayed in the GridGroupHeaderItem.

C#
public string HeaderText { get; set; }
Property Value:

string, copied from the column's HeaderText if this group expression is based on a column. It defaults to the FieldAlias value (if specified).

Meaningful only for fields in the SelectFields collection. When rendering RadGrid will override the FieldAlias value with the HeaderText specified.

Example:
cs-api-definition
GridGroupByField gridGroupByField;

gridGroupByField = new GridGroupByField();
gridGroupByField.FieldName = "EmployeeID";
gridGroupByField.HeaderText = "EmployeeNo";
expression.SelectFields.Add( gridGroupByField );

Gets or sets the string that separates header text from value text as the field is rendered in the GroupHeaderItems.

C#
public string HeaderValueSeparator { get; set; }
Property Value:

string, represents the separator between the header text and value text.

This field value defaults to ": ".

Meaningful only for fields in the SelectFields collection.

Example:
cs-api-definition
GridGroupByField gridGroupByField;

gridGroupByField = new GridGroupByField();
gridGroupByField.FieldName = "EmployeeID";
gridGroupByField.HeaderValueSeparator = " for current group: ";
expression.SelectFields.Add( gridGroupByField );

Gets or sets the value representing how the data will be sorted. Acceptable values are the values of GridSortOrder enumeration except for None (Ascending, Descending).

C#
public GridSortOrder SortOrder { get; set; }
Property Value:

Returns the sorting mode applied to the grouped data. By default it is Ascending.

Meaningful only for fields in the GroupByFields collection. 'None' value is not supported because it can not determine uniquely the order in which the groups will be displayed.

Example:
cs-api-definition
GridGroupByField gridGroupByField;

gridGroupByField = new GridGroupByField();
gridGroupByField.FieldName = "EmployeeID";
gridGroupByField.SortOrder = GridSortOrder.Descending;
expression.GroupByFields.Add( gridGroupByField );

Methods

Inherited but not used

C#
public void CopyFrom(GridGroupByField field)
Parameters:fieldGridGroupByField

Method which gets the FormatString value from GridGroupByField part of the SelectFields collection

C#
public string GetFormatString()
Returns:

string

String containing the FormatString value

Meaningful only for GridGroupByFields from the SelectFields collection

Example:
cs-api-definition
Dim groupExpression As GridGroupByExpression = RadGrid1.MasterTableView.GroupByExpressions(0)
Dim formatString As String = groupExpression.SelectFields(0).GetFormatString()

Method which gets the HeaderText value from GridGroupByField part of the SelectFields collection

C#
public string GetHeaderText()
Returns:

string

String containing the HeaderText value

Meaningful only for GridGroupByFields from the SelectFields collection

Example:
cs-api-definition
Dim groupExpression As GridGroupByExpression = RadGrid1.MasterTableView.GroupByExpressions(0)
Dim headerText as String = groupExpression.SelectFields(0).GetHeaderText()

Method setting the aggregate function applied for a GridGroupByField which is part of the SelectFields collection.

C#
public void SetAggregate(string value)
Parameters:valuestring

Meaningful only for GridGroupByFields from the SelectFields collection

Example:
cs-api-definition
Dim groupExpression As GridGroupByExpression = New GridGroupByExpression()

Dim groupByField As GridGroupByField = New GridGroupByField()
groupByField.FieldName = "Size"
groupByField.SetAggregate(GridAggregateFunction.Sum)
groupExpression.SelectFields.Add(groupByField)

groupByField = New GridGroupByField()
groupByField.FieldName = "Received"
groupExpression.SelectFields.Add(groupByField)

groupByField = New GridGroupByField()
groupByField.FieldName = "Received"
groupExpression.GroupByFields.Add(groupByField)

RadGrid1.MasterTableView.GroupByExpressions.Add(groupExpression)

Method setting the sort order applied for a GridGroupByField which is part of the GroupByFields collection.

C#
public void SetSortOrder(string SortOrder)
Parameters:SortOrderstring

Meaningful only for GridGroupByFields from the GroupByFields collection

Example:
cs-api-definition
GridGroupByExpression groupExpression = new GridGroupByExpression();

groupByField = new GridGroupByField();
groupByField.FieldName = "Received";
groupExpression.SelectFields.Add(groupByField);

groupByField = new GridGroupByField();
groupByField.FieldName = "Received";
groupByField.SetSortOrder(GridSortOrder.Ascending);
groupExpression.GroupByFields.Add(groupByField);

RadGrid1.MasterTableView.GroupByExpressions.Add(groupExpression);

Method that retrieves a System.String that indicates the current object

C#
public override string ToString()
Returns:

string

The string format of the object.

Overrides: object.ToString()

Inherited but not used

C#
public void Validate()