You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: MAUI/DataGrid/Column-types.md
+38-36Lines changed: 38 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -131,7 +131,7 @@ public class DisplayBindingConverter : IValueConverter
131
131
132
132
### Load DataTemplate for Cells
133
133
134
-
You can customize the display of any column in the `SfDataGrid` by setting the [DataGridColumn.CellTemplate](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridColumn.html#Syncfusion_Maui_DataGrid_DataGridColumn_CellTemplate) property. This allows you to format data visually using MAUI controls and apply conditional styling using DataTrigger or Binding. In edit mode, the appropriate editor will be loaded based on the column type.
134
+
You can customize the display of any column in the `SfDataGrid` by setting the [DataGridColumn.CellTemplate](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridColumn.html#Syncfusion_Maui_DataGrid_DataGridColumn_CellTemplate) property. This allows you to format data visually using MAUI controls and apply conditional styling using [DataTrigger](https://learn.microsoft.com/en-us/dotnet/api/system.windows.datatrigger?view=windowsdesktop-9.0) or Binding. In edit mode, the appropriate editor will be loaded based on the column type.
135
135
136
136
{% tabs %}
137
137
{% highlight xaml tabtitle="MainPage.xaml" %}
@@ -159,41 +159,9 @@ You can customize the display of any column in the `SfDataGrid` by setting the [
***Reusing DataTemplate**: To reuse a single DataTemplate across multiple columns, set the [DataGridColumn.SetCellBoundValue](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridColumn.html#Syncfusion_Maui_DataGrid_DataGridColumn_SetCellBoundValue) property to `true`. This changes the BindingContext to a helper object with `Value` (column's mapped value) and `Record` (original data object) properties.
162
+
The `SfDataGrid` also supports using a [DataTemplateSelector](https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/datatemplate#choose-a-datatemplate-based-on-properties-of-the-data-object)to dynamically choose templates based on data. This is useful when you want to apply different styles or layouts depending on the properties of the data object.
***Template Selector**: Use [DataTemplateSelector](https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/datatemplate#choose-a-datatemplate-based-on-properties-of-the-data-object) to choose different DataTemplates based on data object properties.
164
+
In the following example, a custom DataTemplateSelector is used to apply different styles based on whether the OrderID is even or odd.
197
165
198
166
{% tabs %}
199
167
{% highlight xaml tabtitle="MainPage.xaml" %}
@@ -257,6 +225,40 @@ public class CustomCellTemplateSelector : DataTemplateSelector
To reuse a single `DataTemplate` across multiple columns, set the [DataGridColumn.SetCellBoundValue](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridColumn.html#Syncfusion_Maui_DataGrid_DataGridColumn_SetCellBoundValue) property to `true`. This changes the BindingContext to a helper object with `Value` (column's mapped value) and `Record` (original data object) properties.
N> `CellTemplate` is not supported by `DataGridCheckboxColumn`, `DataGridImageColumn` and `DataGridUnboundColumn` columns. When using complex templates, consider the impact on scrolling performance with large datasets.
261
263
262
264
### TextAlignment
@@ -576,7 +578,7 @@ The `DataGridCheckBoxColumn` inherits all the properties of the `DataGridColumn`
576
578

577
579
578
580
N>
579
-
By default, `DataGridCheckBoxColumn` is read-only. To enable editing (allow users to toggle the checkbox), set the column’s AllowEditing property to true.
581
+
By default, `DataGridCheckBoxColumn` is read-only. To enable editing and allow users to toggle the checkbox, set the AllowEditing property to true either at the column level or the grid level.
0 commit comments