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

GridCalculatedColumn displays a value that is calculated based on one or more fields and an expression that indicates how to calculate the display value. Use the DataFields property to list all the fields that are used to calculate the column value. The Expression property then specifies how the field values are to be combined, using parameters based on the order of the fields listed in the DataFields property.

Definition

Namespace:Telerik.Web.UI

Assembly:Telerik.Web.UI.dll

Syntax:

C#
public class GridCalculatedColumn : GridColumn, IStateManager, IComparable, IGridDataColumn

Inheritance: objectGridColumnGridCalculatedColumn

Implements: IComparableIGridDataColumnIStateManager

Inherited Members GridColumn.Initialize()GridColumn.InitializeCell(TableCell, int, GridItem)GridColumn.ShouldSerializeFilterImageUrl()GridColumn.ShouldSerializeSortAscImageUrl()GridColumn.ShouldSerializeSortDescImageUrl()GridColumn.RefreshCurrentFilterValue(GridFilteringItem, string)GridColumn.RefreshCurrentFilterValue(GridFilteringItem)GridColumn.SetCurrentFilterValueToControl(TableCell)GridColumn.GetCurrentFilterValueFromControl(TableCell)GridColumn.EvaluateFilterExpression(GridFilteringItem)GridColumn.EvaluateFilterExpression()GridColumn.FunctionTakesNoArguments(GridKnownFunction)GridColumn.SetupFilterControls(TableCell)GridColumn.GetFilterFunctionsList(GridFilterListOptions, ArrayList)GridColumn.PrepareCell(TableCell, GridItem)GridColumn.LoadViewState(object)GridColumn.OnColumnChanged()GridColumn.SaveViewState()GridColumn.TrackViewState()GridColumn.ResetCurrentFilterValue(GridFilteringItem)GridColumn.ResetCurrentFilterValue()GridColumn.IsUniqueName(string)GridColumn.GenerateUniqueNameBase(string)GridColumn.GenerateUniqueName()GridColumn.TrySetOnClientClickScript(Control, GridItem, string, params string[])GridColumn.UpdateUniqueNameIfDefault(string)GridColumn.IsBoundToFieldName(string)GridColumn.HeaderTooltipGridColumn.HeaderAbbrGridColumn.HeaderAxisGridColumn.SortedBackColorGridColumn.CurrentFilterValueGridColumn.AndCurrentFilterValueGridColumn.ColumnGroupNameGridColumn.SelectedGridColumn.SelectableGridColumn.SortableGridColumn.CurrentFilterFunctionGridColumn.AndCurrentFilterFunctionGridColumn.FilterDelayGridColumn.ExportableGridColumn.EnableHeaderContextMenuGridColumn.ShowFilterIconGridColumn.FilterListOptionsGridColumn.AutoPostBackOnFilterGridColumn.FilterImageToolTipGridColumn.FilterControlToolTipGridColumn.EditorControlToolTipGridColumn.FilterImageUrlGridColumn.SortAscImageUrlGridColumn.SortDescImageUrlGridColumn.DataTypeNameGridColumn.ListOfFilterValuesGridColumn.FilterTemplateGridColumn.TableViewSpecificStateGridColumn.DesignModeGridColumn.FooterStyleGridColumn.FooterTextGridColumn.HeaderImageUrlGridColumn.HeaderStyleGridColumn.HeaderTextGridColumn.IsTrackingViewStateGridColumn.ItemStyleGridColumn.OwnerGridColumn.SortExpressionGridColumn.GroupByExpressionGridColumn.ViewStateGridColumn.ShowSortIconGridColumn.ShowNoSortIconGridColumn.VisibleGridColumn.DisplayGridColumn.OwnerIDGridColumn.OwnerGridIDGridColumn.ResizableGridColumn.ReorderableGridColumn.GroupableGridColumn.ColumnTypeGridColumn.HeaderButtonTypeGridColumn.OrderIndexGridColumn.IsEditableGridColumn.IsDefaultUniqueNameGridColumn.EditFormColumnIndexGridColumn.UniqueNameGridColumn.EditFormHeaderTextFormatGridColumn.DataTypeGridColumn.FilterControlWidthGridColumn.FilterControlAltTextGridColumn.FilterCheckListWebServiceMethodGridColumn.FilterCheckListEnableLoadOnDemandobject.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()object.GetType()object.MemberwiseClone()...

Constructors

C#
public GridCalculatedColumn()

Properties

Gets or sets the field name from the specified data source to bind to the GridCalculatedColumn.

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

A string, specifying the data field from the data source, from which to bind the column.

Gets or sets whether the column data can be filtered. The default value is true.

C#
public virtual bool AllowFiltering { get; set; }
Property Value:

A Boolean value, indicating whether the column can be filtered.

Implements: IGridDataColumn.AllowFiltering

Gets or sets a whether the column data can be sorted.

C#
public virtual bool AllowSorting { get; set; }
Property Value:

A boolean value, indicating whether the column data can be sorted.

Implements: IGridDataColumn.AllowSorting

Gets or sets a string, representing a comma-separated enumeration of DataFields from the data source, which will form the expression.

C#
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
[TypeConverter(typeof(GridStringArrayConverter))]
public virtual string[] DataFields { get; set; }
Property Value:

A string, representing a comma-separated enumeration of DataFields from the data source, which will form the expression.

Gets or sets the string that specifies the display format for items in the column.

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

A string that specifies the display format for items in the column

Use the DataFormatString property to provide a custom format for the items in the column.

The data format string consists of two parts, separated by a colon, in the form { A : Bxx }.
For example, the formatting string {0:C2} displays a currency formatted number with two decimal places.

Note: The entire string must be enclosed in braces to indicate that it is a format string and not a literal string. Any text outside the braces is displayed as literal text.

The value before the colon (A in the general example) specifies the parameter index in a zero-based list of parameters.

Note: This value can only be set to 0 because there is only one value in each cell.

The value before the colon (A in the general example) specifies the parameter index in a zero-based list of parameters.

The character after the colon (B in the general example) specifies the format to display the value in. The following table lists the common formats.

Format character

Description

C

Displays numeric values in currency format.

D

Displays numeric values in decimal format.

E

Displays numeric values in scientific (exponential) format.

F

Displays numeric values in fixed format.

G

Displays numeric values in general format.

N

Displays numeric values in number format.

X

Displays numeric values in hexadecimal format.

Note: The format character is not case-sensitive, except for X, which displays the hexadecimal characters in the case specified.

The value after the format character (xx in the general example) specifies the number of significant digits or decimal places to display.

For more information on formatting strings, see Formatting Overview (external link to MSDN library).

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

The expression used to filter rows, calculate the values in a column, or create an aggregate column.

Sets or gets format string for the footer/group footer aggregate.

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

The footer aggregate format string.

Methods

Creates a copy of the current column.

C#
public override GridColumn Clone()
Returns:

GridColumn

Overrides: GridColumn.Clone()

Note: When implementing/overriding this method be sure to call the base member or call CopyBaseProperties to be sure that all base properties will be copied accordingly

C#
protected override void CopyBaseProperties(GridColumn fromColumn)
Parameters:fromColumnGridColumn

Overrides: GridColumn.CopyBaseProperties(GridColumn)

C#
protected virtual string FormatDataValue(object dataValue)
Parameters:dataValueobjectReturns:

string

For GridCalculatedColumn it is the same as the GetFilterDataField function.

C#
public string GetActiveDataField()
Returns:

string

Implements: IGridDataColumn.GetActiveDataField()

This method should be used in case you develop your own column. It returns the full list of DataFields used by the column. GridTableView uses this to decide which DataFields from the specified DataSource will be inlcuded in case of GridTableView.RetrieveAllDataFields is set to false.

C#
public override IDictionary GetCustomPropertyDataFields(object dataItemInstance)
Parameters:dataItemInstanceobjectReturns:

IDictionary

Overrides: GridColumn.GetCustomPropertyDataFields(object)

Calculate the default Group-by expression based on the settings of the DataField (if available)

C#
public override string GetDefaultGroupByExpression()
Returns:

string

Overrides: GridColumn.GetDefaultGroupByExpression()

For example, if a column's DataField is ProductType the default group-by expression will be: 'ProductType Group By ProductType'

C#
protected override string GetFilterDataField()
Returns:

string

Overrides: GridColumn.GetFilterDataField()

This method should be used in case you develop your own column. It returns true if the column supports filtering.

C#
public override bool SupportsFiltering()
Returns:

bool

Overrides: GridColumn.SupportsFiltering()