GridCalculatedColumn
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:
public class GridCalculatedColumn : GridColumn, IStateManager, IComparable, IGridDataColumn
Inheritance: objectGridColumnGridCalculatedColumn
Implements:
Inherited Members
Constructors
public GridCalculatedColumn()
Properties
Gets or sets the field name from the specified data source to bind to the GridCalculatedColumn.
public virtual GridAggregateFunction Aggregate { get; set; }
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.
public virtual bool AllowFiltering { get; set; }
A Boolean value, indicating whether the column can be filtered.
Implements:
Gets or sets a whether the column data can be sorted.
public virtual bool AllowSorting { get; set; }
A boolean value, indicating whether the column data can be sorted.
Implements:
Gets or sets a string, representing a comma-separated enumeration of DataFields from the data source, which will form the expression.
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
[TypeConverter(typeof(GridStringArrayConverter))]
public virtual string[] DataFields { get; set; }
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.
public virtual string DataFormatString { get; set; }
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).
Gets or sets the expression used to filter rows, calculate the values in a column, or create an aggregate column. http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression(v=vs.71).aspx http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression(v=vs.71).aspx
public virtual string Expression { get; set; }
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.
public virtual string FooterAggregateFormatString { get; set; }
The footer aggregate format string.
Methods
Creates a copy of the current column.
public override GridColumn Clone()
Overrides:
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
protected override void CopyBaseProperties(GridColumn fromColumn)
Overrides:
For GridCalculatedColumn it is the same as the GetFilterDataField function.
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.
public override IDictionary GetCustomPropertyDataFields(object dataItemInstance)
Overrides:
Calculate the default Group-by expression based on the settings of the DataField (if available)
public override string GetDefaultGroupByExpression()
Overrides:
For example, if a column's DataField is ProductType the default group-by expression will be: 'ProductType Group By ProductType'
This method should be used in case you develop your own column. It returns true if the column supports filtering.