Class SfDataGrid
A data bound grid control that displays the data from data source in a tabular view. The SfDataGrid control allows you to display different types of columns, sort and select the rows.
Implements
Inherited Members
Namespace: Syncfusion.Maui.DataGrid
Assembly: Syncfusion.Maui.DataGrid.dll
Syntax
public class SfDataGrid : SfView, IDrawableLayout, IDrawable, IAbsoluteLayout, ILayout, IView, IElement, ITransform, IContainer, IList<IView>, ICollection<IView>, IEnumerable<IView>, IEnumerable, ISafeAreaView, IPadding, IVisualTreeElement
Remarks
To bind the SfDataGrid to data, set the ItemsSource property to an System.Collections.IEnumerable implementation. Each row in the data grid is bound to an object in the data source, and each column in the data grid is bound to a property of the data object. In order for the SfDataGrid user interface to update automatically when items are added to or removed from the source data, the SfDataGrid must be bound to a collection that implements the System.Collections.Specialized.INotifyCollectionChanged interface, such as an System.Collections.ObjectModel.ObservableCollection<>. To automatically reflect property changes, the objects in the source collection must implement the System.ComponentModel.INotifyPropertyChanged interface.
Constructors
SfDataGrid()
Initializes a new instance of the SfDataGrid class.
Declaration
public SfDataGrid()
Fields
AllowTriStateSortingProperty
Identifies the AllowTriStateSorting Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty AllowTriStateSortingProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
AlternationRowCountProperty
Identifies the AlternationRowCount Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty AlternationRowCountProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
AutoGenerateColumnsModeForCustomTypeProperty
Identifies the AutoGenerateColumnsModeForCustomType Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty AutoGenerateColumnsModeForCustomTypeProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
AutoGenerateColumnsModeProperty
Identifies the AutoGenerateColumnsMode Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty AutoGenerateColumnsModeProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
CanMaintainScrollPositionProperty
Identifies theCanMaintainScrollPosition Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty CanMaintainScrollPositionProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
CellRenderersProperty
Identifies the CellRenderers Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty CellRenderersProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
ColumnsProperty
Identifies the Columns Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty ColumnsProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
ColumnWidthModeProperty
Identifies the ColumnWidthMode Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty ColumnWidthModeProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
CurrentCellProperty
Identifies the CurrentCell Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty CurrentCellProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
CurrentRowProperty
Identifies the CurrentRow Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty CurrentRowProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
DefaultColumnWidthProperty
Identifies the DefaultColumnWidth Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty DefaultColumnWidthProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
DefaultStyleProperty
Identifies the DefaultStyle Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty DefaultStyleProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
FrozenColumnCountProperty
Identifies the FrozenColumnCount Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty FrozenColumnCountProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
FrozenRowCountProperty
Identifies the FrozenRowCount Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty FrozenRowCountProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
GridLinesVisibilityProperty
Identifies the GridLinesVisibility Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty GridLinesVisibilityProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
HeaderGridLinesVisibilityProperty
Identifies the HeaderGridLinesVisibility Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty HeaderGridLinesVisibilityProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
HeaderRowHeightProperty
Identifies the HeaderRowHeight Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty HeaderRowHeightProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
HorizontalScrollBarVisibilityProperty
Identifies the HorizontalScrollBarVisibility Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty HorizontalScrollBarVisibilityProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
ItemsSourceProperty
Identifies the ItemsSource Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty ItemsSourceProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
LiveDataUpdateModeProperty
Declaration
public static readonly BindableProperty LiveDataUpdateModeProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
NavigationModeProperty
Identifies the NavigationMode Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty NavigationModeProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
RowHeightProperty
Identifies the RowHeight Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty RowHeightProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
SelectedIndexProperty
Identifies the SelectedIndex Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty SelectedIndexProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
SelectedRowProperty
Identifies the SelectedRow Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty SelectedRowProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
SelectedRowsProperty
Identifies the SelectedRows Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty SelectedRowsProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
SelectionModeProperty
Identifies the SelectionMode Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty SelectionModeProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
ShowSortNumbersProperty
Identifies the ShowSortNumbers Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty ShowSortNumbersProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
SortColumnDescriptionsProperty
Identifies the SortColumnDescriptionCollection Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty SortColumnDescriptionsProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
SortComparersProperty
Identifies the SortComparers Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty SortComparersProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
SortingGestureTypeProperty
Identifies the SortingGestureType Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty SortingGestureTypeProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
SortingModeProperty
Identifies the SortingMode Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty SortingModeProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
StackedHeaderRowsProperty
to do
Declaration
public static readonly BindableProperty StackedHeaderRowsProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
SummaryCalculationModeProperty
Declaration
public static readonly BindableProperty SummaryCalculationModeProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
TableSummaryRowsProperty
Declaration
public static readonly BindableProperty TableSummaryRowsProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
TableSummaryTemplateProperty
Declaration
public static readonly BindableProperty TableSummaryTemplateProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
VerticalScrollBarVisibilityProperty
Identifies the VerticalScrollBarVisibility Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty VerticalScrollBarVisibilityProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
ViewProperty
Identifies the View Microsoft.Maui.Controls.BindableProperty.
Declaration
public static readonly BindableProperty ViewProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
This Microsoft.Maui.Controls.BindableProperty is read-only.
Properties
AllowTriStateSorting
Gets or sets a value indicating whether user can sort the column in three states: ascending, descending, unsorted.
Declaration
public bool AllowTriStateSorting { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
This is applicable only if the DataGridSortingMode is other than None.
AlternationRowCount
Gets or sets a row count to apply the background for the rows alternatively.
Declaration
public int AlternationRowCount { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
AutoGenerateColumnsMode
Gets or sets the AutoGenerateColumnsMode of SfDataGrid control. SfDataGrid decides columns generation based on the AutoGenerateColumnsMode property.
Declaration
public AutoGenerateColumnsMode AutoGenerateColumnsMode { get; set; }
Property Value
Type | Description |
---|---|
AutoGenerateColumnsMode | The AutoGenerateColumnsMode of SfDataGrid.
The default value is |
Remarks
The user can set the mode in which the columns should be generated by using the AutoGenerateColumnsMode property. The user can also customize the automatically generated column by using the AutoGeneratingColumn event. In order to include only the columns defined manually in the Columns collection, the user must set the None.
AutoGenerateColumnsModeForCustomType
Gets or sets the value that indicates how the complex type of properties should be auto-generated.
Declaration
public AutoGenerateColumnsModeForCustomType AutoGenerateColumnsModeForCustomType { get; set; }
Property Value
Type | Description |
---|---|
AutoGenerateColumnsModeForCustomType |
CanMaintainScrollPosition
to do
Declaration
public bool CanMaintainScrollPosition { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
CellRenderers
Gets the GridCellRendererCollection that contains the cell renderers in SfDataGrid. The CellRenderers manages the creation of cells view objects when the cell is scrolled into view and also unloading of the views. Contains logics to place the UIElement inside cells in display and edit mode.
Declaration
public GridCellRendererCollection CellRenderers { get; }
Property Value
Type | Description |
---|---|
GridCellRendererCollection | The collection containing the renderers in the SfDataGrid. |
Remarks
The CellRenderers manages the creation of cells view objects when the cell is scrolled into view and also unloading of the views. Contains logics to place the UIElement inside cells in display and edit mode. The user can implement the renderer by extending it from the renderer he needs and customize the type of cell to be loaded for each column type in editing and normal mode.
Note:When the user overrides the renderer, he needs to replace it in the CellRenderers collection.
For example, if the user implements the
Columns
Gets or sets the Columns collection of the SfDataGrid. The Columns collection contains the columns in the SfDataGrid which are created for each property in the model class. The user can add the various column types to the SfDataGrid based on the requirement by specifying the MappingName which associates the property in the data source.
Declaration
public ColumnCollection Columns { get; set; }
Property Value
Type | Description |
---|---|
ColumnCollection | The columns collection of the SfDataGrid. |
Remarks
The Columns collection contains the columns in the SfDataGrid which are created for each property in the model class. SfDataGrid allows you to define the columns manually by adding the DataGridColumn objects to the Columns collection. There are different types of columns available in SfDataGrid and you can create any column based on your requirement.
Examples
List<GridColumn> myColumnsCollection = new List<GridColumn>();
myColumnsCollection.Add(new DataGridTextColumn() { MappingName = "OrderID" });
myColumnsCollection.Add(new DataGridTextColumn() { MappingName = "EmployeeID" });
myColumnsCollection.Add(new DataGridTextColumn() { MappingName = "CustomerID" });
dataGrid.Columns = myColumnsCollection;
ColumnSizer
Gets or sets the controller which controls the auto size calculation for column widths.
Declaration
public DataGridColumnSizer ColumnSizer { get; set; }
Property Value
Type | Description |
---|---|
DataGridColumnSizer |
ColumnWidthMode
Gets or sets the value that indicates how all the columns` widths of the SfDataGrid are determined.
Declaration
public ColumnWidthMode ColumnWidthMode { get; set; }
Property Value
Type | Description |
---|---|
ColumnWidthMode | The type of ColumnWidthMode that is applied to the SfDataGrid.
The default value is |
Remarks
The user can specify how columns in the SfDataGrid are sized. SfDataGrid applies width for all the DataGridColumn in the Columns collection based on the ColumnWidthMode property.
CurrentCell
Gets or sets a cell coordinates which is currently navigated.
Declaration
public RowColumnIndex CurrentCell { get; set; }
Property Value
Type | Description |
---|---|
RowColumnIndex |
CurrentRow
Gets or sets a row which is currently navigated.
Declaration
public object CurrentRow { get; set; }
Property Value
Type | Description |
---|---|
System.Object |
DefaultColumnWidth
Gets or sets the default column width of the SfDataGrid. DataGridColumn renders in view based on the value of DefaultColumnWidth property in SfDataGrid.
Declaration
public double DefaultColumnWidth { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The default column width of the SfDataGrid. The default value is 100. |
Remarks
Columns are arranged in view based on the
DefaultColumnWidth property when the ColumnWidthMode is
DefaultStyle
Gets or sets the style for the DataGrid. If it is null, the default style will be set.
Declaration
public DataGridStyle DefaultStyle { get; set; }
Property Value
Type | Description |
---|---|
DataGridStyle |
FrozenColumnCount
The number of non-scrolling columns at the left side of SfDataGrid
Declaration
public int FrozenColumnCount { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The default value is 0. |
Remarks
FrozenColumnCount value should be less than the number of columns displayed in the view. For example, if you have 5 columns in the view, you can set the FrozenColumnCount
value to a maximum of 4.
See Also
FrozenRowCount
The number of non-scrolling rows at the top of SfDataGrid
Declaration
public int FrozenRowCount { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The default value is 0. |
Remarks
FrozenRowCount value should be less than the number of rows displayed in the view. For example, if you have 10 rows in the view, you can set the FrozenRowCount
value to a maximum of 9.
See Also
GridLinesVisibility
Gets or sets the visibility of the grid lines for the data rows.
Declaration
public GridLinesVisibility GridLinesVisibility { get; set; }
Property Value
Type | Description |
---|---|
GridLinesVisibility | A GridLinesVisibility that represents whether the horizontal, vertial or both grid lines should be drawn. The default value is Horizontal. |
Remarks
To customize the visibility of the grid lines of the header, you can use HeaderGridLinesVisibility.
HeaderGridLinesVisibility
Gets or sets the visibility of the grid lines for the column headers.
Declaration
public GridLinesVisibility HeaderGridLinesVisibility { get; set; }
Property Value
Type | Description |
---|---|
GridLinesVisibility | A GridLinesVisibility that represents whether the horizontal, vertial or both grid lines should be drawn. The default value is Horizontal. |
Remarks
To customize the visibility of the grid lines of the data rows, you can use GridLinesVisibility.
HeaderRowHeight
Gets or sets the height of a header row.
Declaration
public double HeaderRowHeight { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
HorizontalScrollBarVisibility
Gets or sets a value that controls when the horizontal scrollbar is visible.
Declaration
public ScrollBarVisibility HorizontalScrollBarVisibility { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.ScrollBarVisibility |
Remarks
This API is only available for the WinUI platform.
ItemsSource
Gets or sets an external data source for SfDataGrid, to display the data in the grid. It supports the data sources such as System.Collections.Generic.List<>, System.Collections.ObjectModel.ObservableCollection<>, and so on. ItemsSource property helps to bind the SfDataGrid with the collection of objects.
Declaration
public object ItemsSource { get; set; }
Property Value
Type | Description |
---|---|
System.Object | The items source of the SfDataGrid. |
Remarks
To bind the SfDataGrid to data, set the ItemsSource property to an System.Collections.IEnumerable implementation. Each row in the datagrid is bound to an object in the data source, and each column in the data grid is bound to a property of the data object. In order to update the SfDataGrid user interface automatically when the items are added to or removed from the source data, the SfDataGrid must be bound to a collection that implements the System.Collections.Specialized.INotifyCollectionChanged interface, such as an System.Collections.ObjectModel.ObservableCollection<>. To automatically reflect property changes, the objects in the source collection must implement the System.ComponentModel.INotifyPropertyChanged interface.
LiveDataUpdateMode
Declaration
public LiveDataUpdateMode LiveDataUpdateMode { get; set; }
Property Value
Type | Description |
---|---|
LiveDataUpdateMode |
NavigationMode
Gets or sets the value that indicates the navigation mode in the DataGrid.
Declaration
public DataGridNavigationMode NavigationMode { get; set; }
Property Value
Type | Description |
---|---|
DataGridNavigationMode | A DataGridNavigationMode that represents whether the selection should be navihation based on cell or row. The default value is Cell. |
RowHeight
Gets or sets the default height of the all the rows.
Declaration
public double RowHeight { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Remarks
You can use the HeaderRowHeight property to set the height for header row. In order to fit the rows based on its cells content, use the QueryRowHeight event.
SelectedIndex
Gets or sets an index of the currently selected row.
Declaration
public int SelectedIndex { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
SelectedRow
Gets or sets a row which is currently selected.
Declaration
public object SelectedRow { get; set; }
Property Value
Type | Description |
---|---|
System.Object |
SelectedRows
Gets or sets the collection of rows which are all selected.
Declaration
public ObservableCollection<object> SelectedRows { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.ObjectModel.ObservableCollection<System.Object> |
SelectionMode
Gets or sets a value that indicates how the selection should be applied.
Declaration
public DataGridSelectionMode SelectionMode { get; set; }
Property Value
Type | Description |
---|---|
DataGridSelectionMode | A DataGridSelectionMode that represents whether the single, singledeselect and multiple should be applied for rows. The default value is None. |
ShowSortNumbers
Gets or sets a value indicating whether the sequence number should be displayed on the header cell of sorted column during multi-column sorting.
Declaration
public bool ShowSortNumbers { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
SortColumnDescriptions
Gets or sets the collection of the sort descriptions of column which are sorted.
Declaration
public SortColumnDescriptionCollection SortColumnDescriptions { get; set; }
Property Value
Type | Description |
---|---|
SortColumnDescriptionCollection |
SortComparers
Gets or sets the collection of comparers to sort the columns in custom logic.
Declaration
public SortComparers SortComparers { get; }
Property Value
Type | Description |
---|---|
SortComparers |
SortingGestureType
Gets or sets a value that indicates how the sorting should be initiated.
Declaration
public DataGridSortingGestureType SortingGestureType { get; set; }
Property Value
Type | Description |
---|---|
DataGridSortingGestureType | A DataGridSortingGestureType that represents whether the sorting should be applied on tap or double tap. The default value is Tap. |
SortingMode
Gets or sets the value that indicates how the sorting should be applied.
Declaration
public DataGridSortingMode SortingMode { get; set; }
Property Value
Type | Description |
---|---|
DataGridSortingMode | A DataGridSortingMode that represents whether the single or multiple columns should be sorted. The default value is None. |
StackedHeaderRows
Gets or sets the collection of DataGridStackedHeaderRow to add additional headers to group the column headers.
Declaration
public ObservableCollection<DataGridStackedHeaderRow> StackedHeaderRows { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.ObjectModel.ObservableCollection<DataGridStackedHeaderRow> | The collection of DataGridStackedHeaderRow. The default value is null. |
Examples
<syncfusion:SfDataGrid x:Name="dataGrid" AutoGenerateColumnsMode="None"
ItemsSource="{Binding Employees}">
<syncfusion:SfDataGrid.StackedHeaderRows>
<syncfusion:DataGridStackedHeaderRow>
<syncfusion:DataGridStackedHeaderRow.Columns>
<syncfusion:DataGridStackedColumn
ColumnMappingNames = "EmployeeID,Name"
Text="Employee Details"
/>
</syncfusion:DataGridStackedHeaderRow.Columns>
</syncfusion:DataGridStackedHeaderRow>
</syncfusion:SfDataGrid.StackedHeaderRows>
<syncfusion:SfDataGrid.Columns>
<syncfusion:DataGridTextColumn MappingName = "EmployeeID" />
< syncfusion:DataGridTextColumn MappingName = "Name" />
< syncfusion:DataGridTextColumn MappingName = "Title" />
</ syncfusion:SfDataGrid.Columns>
</syncfusion:SfDataGrid>
SfDataGrid dataGrid = new SfDataGrid();
dataGrid.AutoGenerateColumnsMode = AutoGenerateColumnsMode.None;
dataGrid.Columns.Add(new DataGridTextColumn() { MappingName = "EmployeeID", HeaderText = "Employee ID" });
dataGrid.Columns.Add(new DataGridTextColumn() { MappingName = "Name", HeaderText = "Name" });
dataGrid.Columns.Add(new DataGridTextColumn() { MappingName = "Title", HeaderText = "Title" });
var stackedHeaderRow = new DataGridStackedHeaderRow();
stackedHeaderRow.Columns.Add(new DataGridStackedColumn()
{
ColumnMappingNames = "EmployeeID,Name",
Text = "Employee Details",
});
dataGrid.StackedHeaderRows.Add(stackedHeaderRow);
SummaryCalculationMode
Declaration
public CalculationMode SummaryCalculationMode { get; set; }
Property Value
Type | Description |
---|---|
CalculationMode |
TableSummaryRows
Gets or sets the collection of TableSummaryRows of the SfDataGrid. The table summary value is calculated based on all the records in SfDataGrid. SfDataGrid allows you to add multiple table summary rows either at top or bottom or at both positions
Declaration
public ObservableCollection<DataGridTableSummaryRow> TableSummaryRows { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.ObjectModel.ObservableCollection<DataGridTableSummaryRow> | The collection of DataGridTableSummaryRow of SfDataGrid. |
TableSummaryTemplate
Gets or sets the template that is used to display the contents of a table summary. When this property is set, SfDataGrid loads the template as the content of the entire table summary row.
Declaration
public DataTemplate TableSummaryTemplate { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Controls.DataTemplate |
VerticalScrollBarVisibility
Gets or sets a value that controls when the vertical scrollbar is visible.
Declaration
public ScrollBarVisibility VerticalScrollBarVisibility { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.ScrollBarVisibility |
Remarks
This API is only available for the WinUI platform.
View
ToDo
Declaration
public ICollectionViewAdv View { get; }
Property Value
Type | Description |
---|---|
ICollectionViewAdv |
Methods
ArrangeContent(Rect)
ToDo
Declaration
protected override Size ArrangeContent(Rect bounds)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Maui.Graphics.Rect | bounds |
Returns
Type | Description |
---|---|
Microsoft.Maui.Graphics.Size |
Overrides
ClearSelection()
Clears the selection in a SfDataGrid control.
Declaration
public void ClearSelection()
MeasureContent(Double, Double)
ToDo
Declaration
protected override Size MeasureContent(double widthConstraint, double heightConstraint)
Parameters
Type | Name | Description |
---|---|---|
System.Double | widthConstraint | |
System.Double | heightConstraint |
Returns
Type | Description |
---|---|
Microsoft.Maui.Graphics.Size |
Overrides
MoveCurrentCellTo(RowColumnIndex, Boolean)
Moves the currently focus cell to specified coordinates.
Declaration
public void MoveCurrentCellTo(RowColumnIndex rowColumnIndex, bool needToClearSelection = true)
Parameters
Type | Name | Description |
---|---|---|
RowColumnIndex | rowColumnIndex | Specifies the corresponding row and column index to move the current cell to. |
System.Boolean | needToClearSelection | bool value that determines whether the currently selected rows should be removed when the current cell is moved. |
OnPropertyChanged(String)
Called when the property of DataGrid is changed.
Declaration
protected override void OnPropertyChanged(string propertyName = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName |
ScrollToColumnIndex(Int32, ScrollToPosition, Boolean)
Scroll the SfDataGrid to the specified column index.
Declaration
public Task ScrollToColumnIndex(int columnIndex, ScrollToPosition scrollToColumnPosition, bool canAnimate = true)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | columnIndex | The zero-based index of the column to scroll to. |
Microsoft.Maui.Controls.ScrollToPosition | scrollToColumnPosition | The position in the view to which the column should be scrolled. Default is Microsoft.Maui.Controls.ScrollToPosition.Start. |
System.Boolean | canAnimate | Indicates whether the scrolling should be animated. Default is true. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Returns the task that performs the scrolling asynchronously. |
Remarks
SfDataGrid supports programmatic scrolling. The user can scroll to the
required column by using this method.
See Also
ScrollToRowColumnIndex(Int32, Int32, ScrollToPosition, ScrollToPosition, Boolean)
Scroll the DataGrid to the specified row and column index.
Declaration
public Task ScrollToRowColumnIndex(int rowIndex, int columnIndex, ScrollToPosition scrollToRowPosition, ScrollToPosition scrollToColumnPosition, bool canAnimate = true)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The zero-based index of the row to scroll to. |
System.Int32 | columnIndex | The zero-based index of the column to scroll to. |
Microsoft.Maui.Controls.ScrollToPosition | scrollToRowPosition | The position in the view to which the row should be scrolled. Default is Microsoft.Maui.Controls.ScrollToPosition.Start. |
Microsoft.Maui.Controls.ScrollToPosition | scrollToColumnPosition | The position in the view to which the column should be scrolled. Default is Microsoft.Maui.Controls.ScrollToPosition.Start. |
System.Boolean | canAnimate | Indicates whether the scrolling should be animated. Default is true. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Returns the task that performs the scrolling asynchronously. |
Remarks
SfDataGrid supports programmatic scrolling. The user can scroll to the
required row and column by using this method.
See Also
ScrollToRowIndex(Int32, ScrollToPosition, Boolean)
Scroll the DataGrid to the specified row index.
Declaration
public Task ScrollToRowIndex(int rowIndex, ScrollToPosition scrollToRowPosition, bool canAnimate = true)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | The zero-based index of the column to scroll to. |
Microsoft.Maui.Controls.ScrollToPosition | scrollToRowPosition | The position in the view to which the row should be scrolled. Default is Microsoft.Maui.Controls.ScrollToPosition.Start. |
System.Boolean | canAnimate | Indicates whether the scrolling should be animated. Default is true. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Returns the task that performs the scrolling asynchronously. |
Remarks
SfDataGrid supports programmatic scrolling. The user can scroll to the
required row by using this method.
See Also
SelectAll()
Selects all the cells in SfDataGrid when SelectionMode is Multiple.
Declaration
public void SelectAll()
Events
AutoGeneratingColumn
Occurs when column is generated for the properties from underlying data object.
Declaration
public event EventHandler<DataGridAutoGeneratingColumnEventArgs> AutoGeneratingColumn
Event Type
Type | Description |
---|---|
System.EventHandler<DataGridAutoGeneratingColumnEventArgs> |
CellDoubleTapped
Occurs when the cell is tapped twice.
Declaration
public event EventHandler<DataGridCellDoubleTappedEventArgs> CellDoubleTapped
Event Type
Type | Description |
---|---|
System.EventHandler<DataGridCellDoubleTappedEventArgs> |
CellLongPress
Occurs when the cell is long pressed for particular period.
Declaration
public event EventHandler<DataGridCellLongPressEventArgs> CellLongPress
Event Type
Type | Description |
---|---|
System.EventHandler<DataGridCellLongPressEventArgs> |
CellTapped
Occurs when the cell is tapped.
Declaration
public event EventHandler<DataGridCellTappedEventArgs> CellTapped
Event Type
Type | Description |
---|---|
System.EventHandler<DataGridCellTappedEventArgs> |
CellValueChanged
Occurs when the cell value is changed.
Declaration
public event EventHandler<DataGridCellValueChangedEventArgs> CellValueChanged
Event Type
Type | Description |
---|---|
System.EventHandler<DataGridCellValueChangedEventArgs> |
Remarks
As of now, this event will be triggered for the DataGridCheckBoxColumn. This event won’t be triggered when you change the value of underlying data programmatically.
CurrentCellActivated
Occurs when the cell is activated on tapping or navigation.
Declaration
public event EventHandler<DataGridCurrentCellActivatedEventArgs> CurrentCellActivated
Event Type
Type | Description |
---|---|
System.EventHandler<DataGridCurrentCellActivatedEventArgs> |
CurrentCellActivating
Occurs when the cell is being activated on tapping or navigation.
Declaration
public event EventHandler<DataGridCurrentCellActivatingEventArgs> CurrentCellActivating
Event Type
Type | Description |
---|---|
System.EventHandler<DataGridCurrentCellActivatingEventArgs> |
QueryRowHeight
Occurs when the height of the rows is queried.
Declaration
public event EventHandler<DataGridQueryRowHeightEventArgs> QueryRowHeight
Event Type
Type | Description |
---|---|
System.EventHandler<DataGridQueryRowHeightEventArgs> |
SelectionChanged
Occurs when the selection is applied to rows.
Declaration
public event EventHandler<DataGridSelectionChangedEventArgs> SelectionChanged
Event Type
Type | Description |
---|---|
System.EventHandler<DataGridSelectionChangedEventArgs> |
SelectionChanging
Occurs when the selection is being applied to rows.
Declaration
public event EventHandler<DataGridSelectionChangingEventArgs> SelectionChanging
Event Type
Type | Description |
---|---|
System.EventHandler<DataGridSelectionChangingEventArgs> |
SortColumnsChanged
Occurs when column is sorted.
Declaration
public event EventHandler<DataGridSortColumnsChangedEventArgs> SortColumnsChanged
Event Type
Type | Description |
---|---|
System.EventHandler<DataGridSortColumnsChangedEventArgs> |
SortColumnsChanging
Occurs when column is being sorted.
Declaration
public event EventHandler<DataGridSortColumnsChangingEventArgs> SortColumnsChanging
Event Type
Type | Description |
---|---|
System.EventHandler<DataGridSortColumnsChangingEventArgs> |