GridColumn
A Column is the main logic unit that relates the content of the grid to properties of the objects in the DataSource.
The GridColumn defines the properties and methods that are common to all column types in RadGrid. As it is an abstract class (MustInherit in VB.NET) GridColumn class can not be created directly. You should inherit it and use its children.
GridColumn is the base abstract class that implements the functionality of a grid column. All inherited classes modify the base behavior corresponding to the specific data that should be displayed/edited in RadGrid. The columns that have editing capabilities derrive from GridEditableColumn class. Other instances display data, buttons, and so on in the cells of the grid regarding the type of the Item/row in which the cell resides. In you code you can create only instances of the derrived classes. In order to display a column in the grid you should add it in the corresponding Columns collection. Since the column collection is fully persisted in the ViewSteate you should follow the rules that apply to creating asp.net server controls dynamically, when adding columns to grid tables programmatically.
Definition
Namespace:Telerik.Web.UI
Assembly:Telerik.Web.UI.dll
Syntax:
[SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
[TypeConverter(typeof(ExpandableObjectConverter))]
public abstract class GridColumn : IStateManager, IComparable
Inheritance: objectGridColumn
Derived Classes:
Implements:
Inherited Members
Constructors
Creates and initializes a new column with its base properties.
public GridColumn()
Properties
Gets or sets the current second filter condition function.
public virtual GridKnownFunction AndCurrentFilterFunction { get; set; }
This property returns a value of type Telerik.Web.UI.GridKnownFunction. The possible values are:
GridKnownFunction.Contains
GridKnownFunction.Custom
GridKnownFunction.DoesNotContain
GridKnownFunction.EndsWith
GridKnownFunction.EqualTo
GridKnownFunction.GreaterThan
GridKnownFunction.GridKnownFunction
GridKnownFunction.GreaterThanOrEqualTo
GridKnownFunction.IsEmpty
GridKnownFunction.IsNull
GridKnownFunction.LessThan
GridKnownFunction.LessThanOrEqualTo
GridKnownFunction.NoFilter
GridKnownFunction.NotEqualTo
GridKnownFunction.NotIsEmpty
GridKnownFunction.NotIsNull
GridKnownFunction.StartsWith
Gets or sets a value of the currently applied second filter condition value.
public virtual string AndCurrentFilterValue { get; set; }
This property returns a string, representing the current second filter condition value, for which the column is filtered (the value, which the user has entered in the second filtering text box of the filter header context menu).
Gets or sets a value indicating whether the grid should automatically postback, when the value in the filter text-box changes, and the the focus moves to another element.
public virtual bool AutoPostBackOnFilter { get; set; }
This property returns a Boolean value, indicating whether the grid will postback, once the focus moves to another element, and the text of the filtering textbox has changed.
public virtual string ColumnGroupName { get; set; }
Gets the string representation of the type-name of this instance. The value is used by RadGrid to determine the type of the columns persisted into the ViewState, when recreating the grid after postback. The value is also used by the grid client-side object. This property is read only.
[Browsable(false)]
public virtual string ColumnType { get; }
Gets or sets the current function used for filtering.
public virtual GridKnownFunction CurrentFilterFunction { get; set; }
This property returns a value of type Telerik.Web.UI.GridKnownFunction. The possible values are:
GridKnownFunction.Between
GridKnownFunction.Contains
GridKnownFunction.Custom
GridKnownFunction.DoesNotContain
GridKnownFunction.EndsWith
GridKnownFunction.EqualTo
GridKnownFunction.GreaterThan
GridKnownFunction.GridKnownFunction
GridKnownFunction.GreaterThanOrEqualTo
GridKnownFunction.IsEmpty
GridKnownFunction.IsNull
GridKnownFunction.LessThan
GridKnownFunction.LessThanOrEqualTo
GridKnownFunction.NoFilter
GridKnownFunction.NotBetween
GridKnownFunction.NotEqualTo
GridKnownFunction.NotIsEmpty
GridKnownFunction.NotIsNull
GridKnownFunction.StartsWith
Gets or sets a value of the currently applied filter.
public virtual string CurrentFilterValue { get; set; }
This property returns a string, representing the current value, for which the columns is filtered (the value, which the user has entered in the filtering text box).
Gets or sets (see the Remarks) the type of the data from the DataField as it was set in the DataSource.
[TypeConverter(typeof(GridDataTypeConverter))]
public Type DataType { get; set; }
The DataType property supports the following base .NET Framework data types:
- Boolean
- Byte
- Char
- DateTime
- Decimal
- Double
- Int16
- Int32
- Int64
- SByte
- Single
- String
- TimeSpan
- UInt16
- UInt32
- UInt64
Gets the string representation of the DataType property of the column, needed for the client-side grid instance.
[Browsable(false)]
public string DataTypeName { get; }
protected bool DesignMode { get; }
Gets or sets a value indicating whether the cells corresponding to a column would be rendered with a 'display:none' style attribute (end-user-not-visible). To completely prevent cells from rendering, set the Visible property to false, instead of the Display property.
public bool Display { get; set; }
This property returns a Boolean value, indicating whether the cells corresponding to the column would be rendered with a 'display:none' style attribute (end-user-not-visible).
Specifies the vertical collumn number where this column will appear when using EditForms editing mode and the form is autogenerated. See the remarks for details.
public int EditFormColumnIndex { get; set; }
A practicle example of using this property is to deterimine the number of columns rendered in the edit form. If there will be only one column in the rendered edit form, when we retrieve the value of this property for a column, as shown in the code below:
<pre><code class="lang-csharp">protected void RadGrid1_PreRender(object sender, EventArgs e) { int columnIndex = RadGrid1.MasterTableView.Columns[3].EditFormColumnIndex; }</code></pre>it will be equal to 0, meaning the the column belongs to the first group of columns in the edit form.
String that formats the HeaderText when the column is displayed in an edit form
public string EditFormHeaderTextFormat { get; set; }
Gets or sets the filter control ToolTip property value.
public virtual string EditorControlToolTip { get; set; }
The filter control ToolTip property value.
Determines if the header context menu will be displayed for the current column. This property works together with the EnableHeaderContextMenu property of the corresponding GridTableView. Default value is true.
public virtual bool EnableHeaderContextMenu { get; set; }
Determines whether the given column will be shown in the exported file
public virtual bool Exportable { get; set; }
Get or Set if the Filter Check List will load data on demand from server.
public virtual bool FilterCheckListEnableLoadOnDemand { get; set; }
Get or Set the Methood from CheckListWebServicePath Web Service defined in the TableView, that to be used for getting data for the filter check list
public virtual string FilterCheckListWebServiceMethod { get; set; }
Gets or Sets the text value which should be added to alt attribute of the filter control
public virtual string FilterControlAltText { get; set; }
Gets or sets the filter control ToolTip property value.
public virtual string FilterControlToolTip { get; set; }
The filter control ToolTip property value.
Use this property to set width to the filtering control (depending on the column type, this may be a normal textbox, RadNumericTextBox, RadDatePicker, etc.)
public virtual Unit FilterControlWidth { get; set; }
Gets or sets the filter delay which determines after how many milliseconds a filtering will occur after a filter value have changed.
public virtual int? FilterDelay { get; set; }
The filter delay.
Gets or sets the filter image tool tip.
public virtual string FilterImageToolTip { get; set; }
The filter image tool tip.
Gets or sets a string representing the URL to the image used in the filtering box.
public virtual string FilterImageUrl { get; set; }
A string, representing the URL to the image used in the filtering box.
Gets or sets the value indincating which of the filter functions should be available for that column. For more information see GridFilterListOptions enumaration.
public virtual GridFilterListOptions FilterListOptions { get; set; }
This property returns a value of type Telerik.Web.UI.GridFilterListOptions. The possible values are:
Telerik.Web.UI.GridFilterListOptions.AllowAllFilters
Telerik.Web.UI.GridFilterListOptions.VaryByDataType
Telerik.Web.UI.GridFilterListOptions.VaryByDataTypeAllowCustom
Gets or sets the template, which will be rendered in the filter item cell of the column.
[Browsable(false)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[TemplateContainer(typeof(GridItem), BindingDirection.TwoWay)]
public virtual ITemplate FilterTemplate { get; set; }
A value of type ITemplate.
Style of the cell in the footer item of the grid, corresponding to the column.
[PersistenceMode(PersistenceMode.InnerProperty)]
public virtual TableItemStyle FooterStyle { get; }
Use the FooterText property to specify your own or determine the current text for the footer section of the column.
public virtual string FooterText { get; set; }
Gets or sets a value indicating whether you will be able to group Telerik RadGrid by that column. By default this property is true.
public virtual bool Groupable { get; set; }
A boolean value of either true, when you are able to group by that column, or false.
See Telerik RadGrid manual for details about using grouping. If Groupable is false the column header cannot be dragged to the GroupPanel.
The group-expression that should be used when grid is grouping-by this column. If not set explicitly, RadGrid will generate a group expression based on the DataField of the column (if available), using the GetDefaultGroupByExpression() method.
The grouping can be turned on/off for columns like GridBoundColumn using Groupable property.
For more information about the Group-By expressions and their syntax, see GridGroupByExpression class.
public virtual string GroupByExpression { get; set; }
Gets or sets the column cell 'abbr' attribute.
public virtual string HeaderAbbr { get; set; }
The column cell 'abbr' attribute.
Gets or sets the column cell 'axis' attribute.
public virtual string HeaderAxis { get; set; }
The column cell 'axis' attribute.
Gets or sets the button type of the button rendered in the header item, used for sorting. The possible values that this property accepts are:
Telerik.Web.UI.GridHeaderButtonType.LinkButton
Telerik.Web.UI.GridHeaderButtonType.PushButton
Telerik.Web.UI.GridHeaderButtonType.TextButton
public virtual GridHeaderButtonType HeaderButtonType { get; set; }
The return value for this property is of type Telerik.Web.UI.GridHeaderButtonType
Gets or sets the URL of an image in the cell in the header item of the grid current column. You can use a relative or an absolute URL.
public virtual string HeaderImageUrl { get; set; }
Style of the cell in the header item of the grid, corresponding to the column.
[PersistenceMode(PersistenceMode.InnerProperty)]
public virtual TableItemStyle HeaderStyle { get; }
Use the HeaderText property to specify your own or determine the current text for the header section of the column.
public virtual string HeaderText { get; set; }
Gets or sets the header tooltip of the column.
public virtual string HeaderTooltip { get; set; }
The header tooltip.
protected virtual bool IsDefaultUniqueName { get; }
This property is supposed for developers of new grid columns. It gets whether a column is currently ReadOnly. The ReadOnly property determines whether a column will be editable in edit mode. A column for which the ReadOnly property is true will not be present in the automatically generated edit form.
[Browsable(false)]
public virtual bool IsEditable { get; }
A boolean value, indicating whether a specific column is editable.
protected bool IsTrackingViewState { get; }
Style of the cells, corresponding to the column.
[PersistenceMode(PersistenceMode.InnerProperty)]
public virtual TableItemStyle ItemStyle { get; }
Access the valus passed from the ListBox used for CheckList in the filter.
public virtual string[] ListOfFilterValues { get; set; }
Gets or sets the order index of column in the collection of RenderColumns. Use SwapColumns(string, string) method for reordering the columns.
[Browsable(false)]
public int OrderIndex { get; set; }
integer representing the current column index. You should have in mind that GridExpandColumn and RowIndicatorColumn are always in front of data columns so that's why you columns will start from index 2.
We recommend using this property only for getting the order index for a specific column instead of setting it. Use SwapColumns(string, string) method for reordering columns.
Note that changing the column order index will change the order of the cells in the grid items, after the grid is rebound.
The value of the property would not affect the order of the column in the Columns collection.
Gets the instance of the GridTableVeiw wich owns this column instance.
[Browsable(false)]
public GridTableView Owner { get; }
Gets the value of the ClientID property of the RadGrid instance that owns this column. This property value is used by grid's client object
[Browsable(false)]
public virtual string OwnerGridID { get; }
This property returns a string, which represents a the ClientID for the control.
Gets the value of the ClientID property of the GridTableView that owns this column. This property value is used by grid's client object
[Browsable(false)]
public virtual string OwnerID { get; }
The return value of this property is a string, representing the clientID of the GridTableView, which contains the column. This is the ClientID of the grid instance, followed by "_" and another string, representing the place of the container in the control hierarchy. For the MasterTableView, the default OwnerID for a column will look like: "RadGrid1_ctl01".
Gets or sets a value indicating whether the column can be reordered client-side.
public virtual bool Reorderable { get; set; }
This property returns a boolean value, indicating whether the column is reorderable. The default value is true, meaning that the column can be reordered, using the SwapColumns client side method.
Gets or sets a value indicating whether the column can be resized client-side. You can use this property, by setting it to false, to disable resizing for a particular column, while preserving this functionality for all the other columns.
public virtual bool Resizable { get; set; }
The property returns a boolean value, indicating whether the column can be resized on the client.
Gets the value determining if the column is selectable.
public virtual bool Selectable { get; }
The value determining if the column is selectable.
Indicates whether all column cells have been selected
[Browsable(false)]
public bool Selected { get; set; }
This property returns a bool, indicating if all column cells have been selected.
Gets or sets if the filter icon in the GridFilteringItem will be visible.
public virtual bool ShowFilterIcon { get; set; }
Get or Sets a value indicating whether a no sort icon should appear next to the header button, when a column is not sorted but can be sorted.
public virtual bool ShowNoSortIcon { get; set; }
This property returns a Boolean value, indicating whether a no sort icon should appear next to the header button, when a column is not sorted but can be sorted.
Get or Sets a value indicating whether a sort icon should appear next to the header button, when a column is sorted.
public virtual bool ShowSortIcon { get; set; }
This property returns a Boolean value, indicating whether a sort icon should appear next to the header button, when a column is sorted.
Gets or sets a string representing the URL to the image used for sorting in ascending mode.
public virtual string SortAscImageUrl { get; set; }
A string, representing the URL to the image used for sorting in ascending mode
Gets or sets a string representing the URL to the image used for sorting in descending mode.
public virtual string SortDescImageUrl { get; set; }
A string, representing the URL to the image used for sorting in descending mode
Gets or sets the color of a cell which is sorted.
public virtual Color SortedBackColor { get; set; }
The color of a cell which is sorted.
The string representing a filed-name from the DataSource that should be used when grid sorts by this column. For example: 'EmployeeName'
public virtual string SortExpression { get; set; }
protected StateBag TableViewSpecificState { get; }
Each column in Telerik RadGrid has an UniqueName property (string). This property is assigned automatically by the designer (or the first time you want to access the columns if they are built dynamically).
[Browsable(true)]
public virtual string UniqueName { get; set; }
You can also set it explicitly, if you prefer. However, the automatic generation handles most of the cases. For example a GridBoundColumn with DataField 'ContactName' would generate an UniqueName of 'ContactName'.
Additionally, there may be occasions when you will want to set the UniqueName explicitly. You can do so simply by specifying the custom name that you want to choose:
<pre><code class="lang-csharp"><radG:GridTemplateColumn UniqueName="ColumnUniqueName"></radG:GridTemplateColumn></code></pre>
Gets or sets a value indicating if the column and all corresponding cells would be rendered.
public virtual bool Visible { get; set; }
This property returns a Boolean value, indicating whether the cells corresponding to the column, would be visible on the client, and whether they would be rendered on the client.
Methods
Creates a copy of the current column.
public abstract 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
Evaluates the column filter expression based on the CurrentFilterFunction, CurrentFilterValue, AndCurrentFilterFunction, AndCurrentFilterValue propeties. It could be used to handle custom filtering and is internally used for determining GridTableView FilterExpression value.
Gets a string representing a filter expression, based on the settings of all columns that support filtering, with a syntax ready to be used by a DataView object
public virtual string EvaluateFilterExpression(GridFilteringItem filteringItem)
protected bool FunctionTakesNoArguments(GridKnownFunction filterFunction)
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 virtual IDictionary GetCustomPropertyDataFields(object dataItemInstance)
Calculate the default Group-by expression based on the settings of the DataField (if available)
public virtual string GetDefaultGroupByExpression()
For example, if a column's DataField is ProductType the default group-by expression will be: 'ProductType Group By ProductType'
Gets a list of filter functions based on the settings of the FilterListOptions property.
protected virtual ArrayList GetFilterFunctionsList(GridFilterListOptions options, ArrayList sourceList)
The Initialize method is inherited by a derived GridColumn class. Is is used to reset a column of the derived type.
public virtual void Initialize()
This method is mainly used to reset properties common for all column types derived from GridColumn class.
The Initialize method is usually called during data-binding, prior to the first row being bound.
After a call to this method the column should add the corresponding controls (text, labels, input controls) into the cell given, regarding the inItem type and column index.
Note: This method is called within RadGrid and is not intended to be used directly from your code.
protected virtual void OnColumnChanged()
Modifies the CurrentFilterFunction and CurrentFilterValue properties according to the function given and the corresponding filter text-box control in the filtering item.
public virtual void RefreshCurrentFilterValue(GridFilteringItem filteringItem, string functionName)
Modifies the CurrentFilterValue property according to the corresponding selected item in the filter text-box control in the filtering item.
public virtual void RefreshCurrentFilterValue(GridFilteringItem filteringItem)
Resets the values of the CurrentFilterFunction, CurrentFilterValue, AndCurrentFilterFunction and AndCurrentFilterValue properties to their defaults.
public void ResetCurrentFilterValue()
Resets the values of the CurrentFilterFunction and CurrentFilterValue properties to their defaults.
Sets the value of the property CurrentFilterValue as a text on the TextBox control found in the cell
Instantiates the filter controls (text-box, image.) in the cell given
This method should be used in case you develop your own column. It returns true if the column supports filtering.
protected virtual void TrackViewState()