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
@@ -1012,6 +1018,177 @@ The [DataGridComboBoxColumn.CanFilterSuggestions](https://help.syncfusion.com/cr
1012
1018
{% endhighlight %}
1013
1019
{% endtabs %}
1014
1020
1021
+
## DataGridPickerColumn
1022
+
1023
+
The `DataGridPickerColumn` inherits all the properties of the [SfDataGrid.DataGridColumn](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridColumn.html). It displays a list of items in the form of a [SfPicker](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Picker.SfPicker.html) as the content of a column. To enable or disable editing for a particular column, set the [DataGridColumn.AllowEditing](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridColumn.html#Syncfusion_Maui_DataGrid_DataGridColumn_AllowEditing) property to true or false. When in editing mode, it displays a `SfPicker` element. The data source for the `SfPicker` can be set using the `DataGridPickerColumn.ItemsSource` property. The picker column can be populated with data in the following ways:
1024
+
1025
+
* Collection of primitive types
1026
+
* Collection of user-defined types (custom objects)
1027
+
1028
+

1029
+
1030
+
### Collection of primitive types
1031
+
1032
+
To display the collection of items in the Picker drop-down, create a `DataGridPickerColumn` and set its `ItemsSource` property to a simple collection.
1033
+
1034
+
To load the `DataGridPickerColumn` with a simple string collection, you can refer to the code example below:
To display a list of user-defined items in the picker, create a `DataGridPickerColumn` and set its `ItemsSource` property to a user-defined collection. By default, if the `DisplayMemberPath` is not set, the picker column will display the values from the `MappingName` property of the column.
1109
+
1110
+
#### Display member path
1111
+
1112
+
Displays a value by comparing values of the properties set as `DataGridColumn.MappingName` and `ValueMemberPath` in their respective underlying collections. If the values of `ValueMemberPath` property contains the current value of `MappingName` property, its corresponding value of `DisplayMemberPath` property is displayed in the `DataGridCell`. Or else the `DataGridCell` appears blank. However, in edit mode the values of the `DisplayMemberPath` property are displayed as picker items.
1113
+
1114
+
#### Value member path
1115
+
1116
+
Once editing completed, the column having the `MappingName` equal to the `ValueMemberPath` has its data changed to the corresponding `ValueMemberPath` value for the selected `DisplayMemberPath` value in the picker.
1117
+
1118
+
### Loading different ItemSource for each row of DataGridPickerColumn
1119
+
1120
+
To load different ItemSources for each row of a DataGridPickerColumn, you can utilize the `DataGridPickerColumn.ItemsSourceSelector` property.
1121
+
1122
+
### Implementing IItemsSourceSelector
1123
+
1124
+
`DataGridPickerColumn.ItemsSourceSelector` needs to implement the IItemsSourceSelector interface, which requires you to implement the GetItemsSource method. This method receives the following parameters:
1125
+
1126
+
* Record: This is the data object associated with the row.
1127
+
* Data Context: This is the binding context of the data grid.
1128
+
1129
+
In the provided code, the ItemsSource for the ShipCity column is returned based on the value of the ShipCountry column. This is done by using the record and the binding context of the data grid, which are passed to the GetItemsSource method.
public class ItemSourceSelector : IItemsSourceSelector
1163
+
{
1164
+
public IEnumerable GetItemsSource(object record, object dataContext)
1165
+
{
1166
+
if (record == null)
1167
+
{
1168
+
return null;
1169
+
}
1170
+
1171
+
var orderinfo = record as DealerInfo;
1172
+
var countryName = orderinfo.ShipCountry;
1173
+
var viewModel = dataContext as EditingViewModel;
1174
+
1175
+
// Returns ShipCity collection based on ShipCountry.
1176
+
if (viewModel.ShipCities.ContainsKey(countryName))
1177
+
{
1178
+
string[] shipcities = null;
1179
+
viewModel.ShipCities.TryGetValue(countryName, out shipcities);
1180
+
return shipcities.ToList();
1181
+
}
1182
+
1183
+
return null;
1184
+
}
1185
+
}
1186
+
{% endhighlight %}
1187
+
{% endtabs %}
1188
+
1189
+

1190
+

1191
+
1015
1192
## DataGridNumericColumn
1016
1193
1017
1194
The `DataGridNumericColumn` inherits all the properties of the `DataGridColumn`. It is used to display numeric data. To create a `DataGridNumericColumn`, the property corresponding to the column in the underlying collection must be a numeric type (int, double, float, etc.).
The [SfDataGrid.CellValueChanged](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.SfDataGrid.html) event will be triggered whenever the current cell's value has been changed in the DataGridTextColumn, DataGridNumericColumn, DataGridDateColumn, DataGridComboBoxColumn or DataGridCheckBoxColumn. This event handler contains the parameter of type [DataGridCellValueChangedEventArgs](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridCellValueChangedEventArgs.html) that contains the following properties.
351
+
The [SfDataGrid.CellValueChanged](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.SfDataGrid.html) event will be triggered whenever the current cell's value has been changed in the DataGridTextColumn, DataGridNumericColumn, DataGridDateColumn, DataGridComboBoxColumn, DataGridPickerColumn or DataGridCheckBoxColumn. This event handler contains the parameter of type [DataGridCellValueChangedEventArgs](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridCellValueChangedEventArgs.html) that contains the following properties.
352
352
353
353
*[Column](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridCellValueChangedEventArgs.html#Syncfusion_Maui_DataGrid_DataGridCellValueChangedEventArgs_Column) : Gets the current `DataGridColumn` that contains the grid cell for which value is edited or changed.
354
354
*[NewValue](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridCellValueChangedEventArgs.html#Syncfusion_Maui_DataGrid_DataGridCellValueChangedEventArgs_NewValue) : The newly edited value to be committed.
Copy file name to clipboardExpand all lines: MAUI/DataGrid/overview.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ The .NET MAUI DataGrid control is used to display and manipulate data in a tabul
18
18
19
19
***Data Binding** - Bind different types of data sources, including DataTable.
20
20
21
-
***Column Types** - Show different data types in different types of columns. The following column types are supported: numeric, text, date, checkbox, image, combobox and template. The template column is used to load any control in a column.
21
+
***Column Types** - Show different data types in different types of columns. The following column types are supported: numeric, text, date, checkbox, image, combobox, picker and template. The template column is used to load any control in a column.
22
22
23
23
***Column Resizing** - Interactive support to adjust the width of columns.
0 commit comments