Class GridColumn
Serves as the base class for the different column types of the SfDataGrid control.
Inheritance
Implements
Namespace: Syncfusion.SfDataGrid
Assembly: Syncfusion.SfDataGrid.Android.dll
Syntax
public abstract class GridColumn : Object, IDisposable
Remarks
This abstract class provides the base functionality for all SfDataGrid columns.
Constructors
GridColumn()
Initializes a new instance of the GridColumn class.
Declaration
public GridColumn()
Properties
ActualWidth
Gets the actual width of the grid column.
Declaration
public double ActualWidth { get; }
Property Value
Type | Description |
---|---|
System.Double | The actual width of the grid column. |
AllowEditing
Gets or sets a value indicating whether to enable/disable editing for a column. The user can enable or disable editing for particular column by using this property.
Declaration
public bool AllowEditing { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if editing for the column is enabled, otherwise false. The default value is false. |
Examples
GridTextColumn column = new GridTextColumn();
column.AllowEditing = false;
See Also
AllowSorting
Gets or sets a value indicating whether the column can be sorted or not.
Declaration
public bool AllowSorting { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if sorting for the column is enabled, otherwise false. The default value is true. |
Remarks
SfDataGrid allows sorting for the column only when both AllowSorting and AllowSorting is true. This enables the user to restrict a particular column from being sorted by setting AllowSorting as false.
Examples
GridTextColumn column = new GridTextColumn();
column.AllowSorting = false;
CellTextSize
Gets or sets the font size for the content of record cells in the column. The font size for the content of record cells in the GridColumn can be customized by using this property.
Declaration
public float CellTextSize { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The font size for the content of record cells in the column. The default value is 14. |
Examples
DataGrid.Columns.Add (new GridTextColumn () {
MappingName = "Freight",
CellTextSize = 12
});
See Also
CellType
Gets or sets the cell type of the GridColumn. This property is used to identify the type of the column. This property must be specified with a string value when creating a custom column extending from the base class.
Declaration
public string CellType { get; protected set; }
Property Value
Type | Description |
---|---|
System.String | The CellType of the GridColumn. |
Remarks
SfDataGrid enables the user to create their own column type when the available column type does not meet his requirements. The user must set the CellType of the grid column to the type of UIElement to be loaded in the grid cell. It is mandatory to create a custom cell renderer for the custom column created and it must be added in the CellRenderers collection. The user can handle his customizations in the custom renderer class implementing the GridVirtualizingCellRenderer<T1, T2>.
Examples
StepperColumn stepperColumn = new StepperColumn();
stepperColumn.MappingName = "OrderID";
DataGrid.Columns.Add(stepperColumn);
DataGrid.CellRenderers.Add("Stepper", new StepperColumnRenderer());
//StepperColumn.cs
public class StepperColumn : GridColumn
{
public StepperColumn()
{
CellType = "Stepper";
}
}
//StepperColumnRenderer.cs
public class StepperColumnRenderer : GridVirtualizingCellRenderer<Stepper,Stepper>
{
}
ColumnSizer
Gets or sets the value that indicates how the column width is determined.
Declaration
public ColumnSizer ColumnSizer { get; set; }
Property Value
Type | Description |
---|---|
ColumnSizer | One of the ColumnSizer enumeration that adjust the column width. The default value is none. |
Examples
GridNumericColumn numericColumn = new GridNumericColumn();
numericColumn.ColumnSizer = ColumnSizer.Star;
CultureInfo
Gets or sets the Culture used for formatting the content of record cells in the column. SfDataGrid enables the user to apply different culture to the records in the cells by setting this property.
Declaration
public CultureInfo CultureInfo { get; set; }
Property Value
Type | Description |
---|---|
System.Globalization.CultureInfo | The Culture used for formatting the content of record cells in the column. |
Remarks
SfDataGrid allows you to apply different System.Globalization.CultureInfo for the GridColumns by using this property. Assign the FormatString to this property based on the type of the property the column is associated with to format the value. The user can use different StringFormats to customize the value displayed in the record cells.
Examples
DataGrid.Columns.Add (new GridTextColumn () {
MappingName = "Freight",
Format = "C",
CultureInfo = new CultureInfo("en-US")
});
See Also
Format
Gets or sets a value that indicates the format applied for the content of record cells in the column. SfDataGrid enables the user to apply Format for the records in the cells by setting this property.
SfDataGrid enables the user to populate the data for the GridUnboundColumn using this property. This property enables the user to format the values of other columns and display the formatted value in unbound column.
Declaration
public string Format { get; set; }
Property Value
Type | Description |
---|---|
System.String | The format applied to the record in the cells. |
Remarks
SfDataGrid enables the user to apply Format for the records in the cells by setting this property. Assign the FormatString to this property based on the type of the property the GridColumn is associated with to format the value.
SfDataGrid enables the user to populate the data for the GridUnboundColumn using this property. This property enables the user to format the values of other columns and display the formatted value in unbound column.
Examples
DataGrid.Columns.Add (new GridTextColumn () {
MappingName = "ShippingDate",
Format = "dd/MM/yyyy"
});
GridUnboundColumn DiscountColumn = new GridUnboundColumn()
{
MappingName = "DiscountPrice",
HeaderText = "Discount Price",
Format = "'{Discount}% for {OrderID}'"
};
DataGrid.Columns.Add(DiscountColumn);
See Also
GroupMode
Gets or sets a value that decides whether grouping is processed based on display value or edit value or value in the underlying collection of the column.
Declaration
public DataReflectionMode GroupMode { get; set; }
Property Value
Type | Description |
---|---|
DataReflectionMode | The DataReflectionMode that decides whether grouping is processed based on display value or edit value or value in the underlying collection of the column. The default value is Default. |
Remarks
By default, column grouping occurs based on the value in the underlying collection thereby creating a new group for each new value of that column. SfDataGrid also allows the user to group a column either on the display value or edit value of the column using this property.
Examples
GridNumericColumn cargoWeight = new GridTextColumn();
cargoWeight.MappingName = "ShipmentWeight";
cargoWeight.GroupMode = Syncfusion.Data.DataReflectionMode.Display;
cargoWeight.Format = "#";
See Also
HeaderCellTextSize
Gets or sets the font size for the content of header cell in the column. The font size for the Content of header cell in the GridColumn can be customized by using the this property.
Declaration
public float HeaderCellTextSize { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The font size for the content of header cell in the column. The default value is 14. |
Remarks
The font size for the content of header cell in the GridColumn can be customized by using the this property. However this property will not work if HeaderTemplate is used for a column.
Examples
DataGrid.Columns.Add (new GridTextColumn () {
MappingName = "Freight",
HeaderCellTextSize = 16
});
See Also
HeaderFont
Gets or sets the font for the content of header cell in the column. The Font for the content of header cells in the GridColumn can be customized by using this property.
Declaration
public Typeface HeaderFont { get; set; }
Property Value
Type | Description |
---|---|
Android.Graphics.Typeface | The font for the content of header cell in the column. The default value is "Roboto-Bold". |
Examples
DataGrid.Columns.Add (new GridTextColumn () {
MappingName = "Freight",
HeaderFont = Typeface.Create(Typeface.CreateFromAsset(Application.Context.Assets, "Roboto-Regular.ttf"), TypefaceStyle.Normal);
});
See Also
HeaderTemplate
Gets or sets the view used to display the header of the current column. SfDataGrid allows you to customize the header cell based on your requirement by using this property.
Declaration
public View HeaderTemplate { get; set; }
Property Value
Type | Description |
---|---|
Android.Views.View | The view used to display the header of the current column. |
Examples
TextView textView = new TextView(this);
textView.Text = "OrderID";
textView.SetBackgroundColor(Color.Gray);
GridTextColumn column = new GridTextColumn()
{
MappingName = "OrderID",
HeaderTemplate = textView
};
See Also
HeaderText
Gets or sets the display text of the column header.
Declaration
public string HeaderText { get; set; }
Property Value
Type | Description |
---|---|
System.String | The display text of the column header. The default value of header text is the MappingName of the column. |
Examples
GridTextColumn column = new GridTextColumn();
column.MappingName = "OrderID";
column.HeaderText = "Order ID";
See Also
HeaderTextAlignment
Gets or sets the text alignment for the header cell in the column.
Declaration
public GravityFlags HeaderTextAlignment { get; set; }
Property Value
Type | Description |
---|---|
Android.Views.GravityFlags | The text alignment for the header cell in the column. The default value is Android.Views.GravityFlags.Center. |
Examples
DataGrid.Columns.Add (new GridTextColumn () {
MappingName = "Freight",
HeaderTextAlignment = GravityFlags.Left;
});
See Also
HeaderTextMargin
Gets or sets the padding applied to the header cells in the column.
Declaration
public Thickness HeaderTextMargin { get; set; }
Property Value
Type | Description |
---|---|
Thickness | The padding applied to the header cells in the column. |
Examples
GridTextColumn column = new GridTextColumn();
column.HeaderTextMargin = new Thickness(10,5,10,5);
IsHidden
Gets or sets a value indicating whether the visibility of the column. SfDataGrid allows you to hide a particular column using this property.
Declaration
public bool IsHidden { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the column is hidden, otherwise false. The default value is false. |
Remarks
SfDataGrid allows you to hide a particular column by two ways, the user can either set IsHidden property as true or set Width as 0.
Examples
DataGrid.Columns.Add (new GridTextColumn () {
MappingName = "Freight",
IsHidden = true
});
See Also
LineBreakMode
Gets or sets the LineBreakMode for the cells in the column. The user can customize the line breaking mode of SfDataGrid by using this property. By default, the word will be wrapped in the record cells, when the text for the record cells exceeds the content area.
Declaration
public LineBreakMode LineBreakMode { get; set; }
Property Value
Type | Description |
---|---|
LineBreakMode | The LineBreakMode for the cells in the column. The default value is WordWrap |
Examples
DataGrid.Columns.Add (new GridTextColumn () {
MappingName = "Freight",
LineBreakMode = LineBreakMode.NoWrap;
});
LoadUIView
Gets or sets a value indicating whether to load UIView or draw cell value in Android.
Declaration
public bool LoadUIView { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if UIView is loaded in the grid cell, otherwise false. The default value is false for Android platform and true for iOS platforms. |
Remarks
By default, SfDataGrid draws the value in the cell for Android platform. The user can customize the SfDataGrid to load the UIElement for android platform, by setting LoadUIView as true.
Examples
GridTextColumn column = new GridTextColumn();
column.LoadUIView = true;
MappingName
Gets or sets the mapping name that associates the column with a property in the bound data source.
Declaration
public string MappingName { get; set; }
Property Value
Type | Description |
---|---|
System.String | The mapping name that associates the column with a property in the data source. |
Examples
GridTextColumn column = new GridTextColumn();
column.MappingName = "OrderID";
See Also
MaximumWidth
Gets or sets the upper bound for the width of the column.
Declaration
public double MaximumWidth { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The maximum width constraint of the column. The default value is double.NaN. |
Remarks
When AllowResizingColumn is enabled, the column can be resized from MinimumWidth to MaximumWidth. Hence, using this property the user can restrict the minimum width the column can be resized.
Examples
DataGrid.Columns.Add (new GridTextColumn () {
MappingName = "Freight",
MaximumWidth = 200
});
See Also
MinimumWidth
Gets or sets the lower bound for the width of the column.
Declaration
public double MinimumWidth { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The minimum width constraint of the column. The default value is 20 . |
Remarks
When AllowResizingColumn is enabled, the column can be resized from MinimumWidth to MaximumWidth. Hence, using this property the user can restrict the minimum width the column can be resized.
Examples
DataGrid.Columns.Add (new GridTextColumn () {
MappingName = "Freight",
MinimumWidth = 30
});
See Also
RecordFont
Gets or sets the font for the content of record cells in the column. The font for the content of record cells in the GridColumn can be customized by using this property.
Declaration
public Typeface RecordFont { get; set; }
Property Value
Type | Description |
---|---|
Android.Graphics.Typeface | The font for the content of record cells in the column. The default value is "Roboto-Regular". |
Examples
DataGrid.Columns.Add (new GridTextColumn () {
MappingName = "Freight",
RecordFont = Typeface.Create(Typeface.CreateFromAsset(Application.Context.Assets, "Roboto-Regular.ttf"), TypefaceStyle.Normal);
});
See Also
SortMode
Gets or sets a value�that decides�whether sorting calculation is processed based on display value in case of indexer and complex properties or default value in case of CLR properties
of the column.
Declaration
public DataReflectionMode SortMode { get; set; }
Property Value
Type | Description |
---|---|
DataReflectionMode | The DataReflectionMode that decides�whether sorting calculation is processed based on display value or default value. The default value is Default. |
Remarks
By default, the sorting for the column will be calculalted using DataReflectionMode Defaultonly.
For complex properties use DataReflectionMode.Display to fetch values using custom logic.
For simple CLR properties use DataReflectionMode.Default to fetch values using default logic.
Examples
GridTextColumn cargoWeight = new GridTextColumn();
cargoWeight.MappingName = "ShipmentWeight";
cargoWeight.SortMode = Syncfusion.Data.DataReflectionMode.Display;
TextAlignment
Gets or sets the text alignment for the record cells in the column.
Declaration
public GravityFlags TextAlignment { get; set; }
Property Value
Type | Description |
---|---|
Android.Views.GravityFlags | The text alignment for the record cells in the column. The default value is Android.Views.GravityFlags.Center. |
Examples
DataGrid.Columns.Add (new GridTextColumn () {
MappingName = "Freight",
TextAlignment = GravityFlags.Left;
});
See Also
TextMargin
Gets or sets the padding applied to the record cells in the column.
Declaration
public Thickness TextMargin { get; set; }
Property Value
Type | Description |
---|---|
Thickness | The padding applied to the record cells in the column. |
Examples
GridTextColumn column = new GridTextColumn();
column.TextMargin = new Thickness(10,5,10,5);
UserCellType
Gets or sets the UserCellType of the grid column. This property is used when the user needs a template column. The user can create a template column to load the content of the cell in the GridColumns with your own view by creating custom GridCell to render in the column.
Declaration
public Type UserCellType { get; set; }
Property Value
Type | Description |
---|---|
System.Type | The type of the cell in which the content of the cell is displayed. |
Examples
GridTextColumn customerIdColumn = new GridTextColumn ();
customerIdColumn.UserCellType = typeof(CustomCell);
customerIdColumn.MappingName = "CustomerID";
customerIdColumn.HeaderText = "Customer ID";
DataGrid.Columns.Add(customerIdColumn);
//CustomCell.cs
public class CustomCell : GridCell
{
}
See Also
Width
Gets or sets the column width. The user can customize the column width by using this property. By default, this property will not be assigned any value and the GridColumn renders in view based on the value of DefaultColumnWidth property.
Declaration
public double Width { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The width of the column. The default value is System.Double.NaN |
Examples
DataGrid.Columns.Add (new GridTextColumn () {
MappingName = "Freight",
Width = 100
});
See Also
Methods
CanEditCell()
Determines whether the column is editable.
Declaration
protected virtual bool CanEditCell()
Returns
Type | Description |
---|---|
System.Boolean | Returns true if all the cells with in the column is editable . |
Dispose()
Releases the resources used by the component.
Declaration
public void Dispose()
Dispose(Boolean)
Releases the unmanaged resources used by the component and optionally releases the managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | if true - release both managed and unmanaged resources; if false - release only unmanaged resources. |
GetFormattedValue(Object)
Gets the Formatted value for the content of a record cell in the column based on the Format and CultureInfo of the column.
Declaration
public virtual object GetFormattedValue(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The actual value of the record cell in the column. |
Returns
Type | Description |
---|---|
System.Object | The formatted value based on the Format and CultureInfo properties of the column. |
SetGrid(SfDataGrid)
Sets the reference of the SfDataGrid.
Declaration
protected void SetGrid(SfDataGrid grid)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | The SfDataGrid. |