Skip to content

Commit 48d64f5

Browse files
Merge pull request #3847 from syncfusion-content/MAUI-MultiColumnComboBox-Column-UG
MAUI - SfDataGrid - UG for DataGridMultiColumnComboBox Column
2 parents 7977f67 + f229084 commit 48d64f5

5 files changed

+166
-0
lines changed

MAUI/DataGrid/Column-types.md

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ The following table describes the types of columns and their usage:
7474
<td>To display a Picker within each cell</td>
7575
</tr>
7676
<tr>
77+
<td>{{'[DataGridMultiColumnComboBoxColumn]()'| markdownify }}</td>
78+
<td>{{'[DataGridMultiColumnComboBoxCellRenderer]()'| markdownify }}</td>
79+
<td>MultiColumnComboBox</td>
80+
<td>Use to display the IEnumerable data using [SfMultiColumnComboBox]() .</td>
81+
</tr>
82+
<tr>
7783
<td>{{'[DataGridUnboundColumn](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridUnboundColumn.html)'| markdownify }}</td>
7884
<td>{{'[DataGridUnboundCellRenderer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridUnboundCellRenderer.html)'| markdownify }}</td>
7985
<td>Unbound</td>
@@ -1418,6 +1424,166 @@ The `DataGridNumericColumn` allows formatting the numeric data with culture-spec
14181424

14191425
* `NullValue` - To set the null value when the numeric cell value is null, use the [DataGridNumericColumn.NullValue](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridNumericColumn.html#Syncfusion_Maui_DataGrid_DataGridNumericColumn_NullValue) property.
14201426

1427+
## DataGridMultiColumnComboBoxColumn
1428+
1429+
The `DataGridMultiColumnComboBoxColumn` displays enumeration as cell contents and hosts a (SfMultiColumnComboBox)[] in editing mode. This column type allows you to define the predefined columns in its drop-down, similar to SfDataGrid.
1430+
1431+
You can change the value by selecting the item from drop down or by editing the entry in `SfMultiColumnComboBox`. To disable text editing, set the (IsTextReadOnly)[] property to `true`.
1432+
1433+
{% tabs %}
1434+
{% highlight xaml %}
1435+
<syncfusion:SfDataGrid x:Name = "dataGrid"
1436+
ItemsSource = "{Binding Orders}"
1437+
AllowEditing = "True"
1438+
SelectionMode = "Single"
1439+
AutoGenerateColumnsMode = "None"
1440+
NavigationMode="Row">
1441+
<syncfusion:SfDataGrid.Columns>
1442+
<syncfusion:DataGridMultiColumnComboBoxColumn AutoGenerateColumnsMode = "None"
1443+
MappingName = "CustomerID"
1444+
ItemsSource = "{Binding OrderDetails}"
1445+
DisplayMember = "CustomerID"
1446+
ValueMember = "CustomerID"
1447+
HeaderText="Customer ID">
1448+
<syncfusion:DataGridMultiColumnComboBoxColumn.Columns>
1449+
<syncfusion:DataGridTextColumn MappingName = "CustomerID" HeaderText = "Customer ID"/>
1450+
<syncfusion:DataGridNumericColumn MappingName = "ProductID" HeaderText = "Product ID"/>
1451+
</syncfusion:DataGridMultiColumnComboBoxColumn.Columns>
1452+
</syncfusion:DataGridMultiColumnComboBoxColumn>
1453+
</syncfusion:SfDataGrid.Columns>
1454+
</syncfusion:SfDataGrid>
1455+
1456+
{% endhighlight %}
1457+
1458+
{% highlight c# %}
1459+
var column = new DataGridMultiColumnComboBoxColumn()
1460+
{
1461+
MappingName = "CustomerID",
1462+
HeaderText = "Customer ID",
1463+
ValueMember = "CustomerID",
1464+
DisplayMember = "CustomerID",
1465+
ItemsSource = viewModel.OrderDetails,
1466+
AutoGenerateColumns = false,
1467+
Columns = new ColumnCollection()
1468+
{
1469+
new DataGridTextColumn() { MappingName = "CustomerID" },
1470+
new DataGridNumericColumn() { MappingName = "ProductID" }
1471+
}
1472+
};
1473+
this.dataGrid.Columns.Add(column);
1474+
1475+
{% endhighlight %}
1476+
1477+
{% endtabs %}
1478+
1479+
SfDataGrid triggers, (CurrentCellDropDownSelectionChanged)[] event, when the SelectedValue is changed. (CurrentCellDropDownSelectionChangedEventArgs)[] of `CurrentCellDropDownSelectionChanged` event provides the information about the changed cell value.
1480+
1481+
`SelectedIndex` property returns the index of selected item.
1482+
`SelectedItem` property returns the selected item from drop down list.
1483+
1484+
<img alt="DataGridMultiColumnComboBox column .NET MAUI DataGrid" src="Images\column-types\maui-datagrid-MultiColumn-ComboBox-column.png" width="404"/>
1485+
1486+
### Auto-complete support
1487+
1488+
You can enable the `SfMultiColumnComboBox` to automatically complete the entered input value by setting the (AllowAutoComplete)[] property to `true`. When enabled, this property compares the entered text with each item in the underlying data source of `DataGridMultiColumnComboBoxColumn` and autocomplete the input with the matched value based on the DisplayMember.
1489+
1490+
### Filtering
1491+
1492+
You can enable the `SfMultiColumnComboBox` to dynamically filter the drop-down list items based on the text typed in the entry by setting (AllowIncrementalFiltering)[] property to `true`. Additionally, `DataGridMultiColumnComboBoxColumn` allows filtering based on case sensitivity by setting (AllowCaseSensitiveFiltering)[] to `true`. These features help users to quickly select items from large list.
1493+
1494+
<img alt="DataGridMultiColumnComboBox column with Filtering .NET MAUI DataGrid" src="Images\column-types\maui-datagrid-MultiColumn-ComboBox-column-filtering.png" width="404"/>
1495+
1496+
### Null value support
1497+
1498+
You can allow null values in the column by setting the (AllowNullValue)[] property to `true`.
1499+
1500+
N>
1501+
The AllowNullValue will work only when the underlying property type is Nullable.
1502+
1503+
### Popup Size Customization
1504+
1505+
You can change the size of drop-down popup by setting (PopupWidth)[] and (PopupHeight)[] properties. If these values are not set, the popup width defaults to the `PopupMinWidth` property, which is 200.0 by default. Similarly, the popup height defaults to the `PopupMinHeight` property, which is 300.0 by default.
1506+
1507+
Additionally, `SfMultiColumnComboBox` can automatically adjust the popup width based on the actual size of the SfDataGrid by setting the (IsAutoPopupSize)[] property to `true`.
1508+
1509+
### Loading different ItemsSource for each row
1510+
1511+
You can load different ItemsSource to each row of `DataGridMultiColumnComboBoxColumn` by setting the `SfDataGrid.ItemsSourceSelector` property.
1512+
1513+
### Implementing IItemsSourceSelector
1514+
1515+
`ItemsSourceSelector` must implement the `IItemsSourceSelector` interface, which requires the implementation of the `GetItemsSource` method. The `GetItemsSource` method receives the following parameters:
1516+
1517+
* **Record** – The data object associated with row.
1518+
* **Data Context** – The data context of data grid.
1519+
1520+
In the following example, the items source for `ShipCity` column is returned based on the value of the `ShipCountry` column, using the record and data context passed to the `GetItemsSource` method.
1521+
1522+
{% tabs %}
1523+
{% highlight xaml %}
1524+
<ContentPage.Resources>
1525+
<local:ItemsSourceSelector x:Key = "itemSourceSelector"/>
1526+
</ContentPage.Resources>
1527+
1528+
<syncfusion:SfDataGrid ItemsSource = "{Binding Orders}"
1529+
AllowEditing = "True"
1530+
SelectionMode = "Single"
1531+
AutoGenerateColumnsMode = "None">
1532+
<syncfusion:SfDataGrid.Columns>
1533+
<syncfusion:DataGridNumericColumn MappingName = "OrderID" HeaderText = "Order ID" Format = "D"/>
1534+
<syncfusion:DataGridMultiColumnComboBoxColumn AutoGenerateColumnsMode = "None"
1535+
DisplayMember = "ShipCity"
1536+
HeaderText = "Ship City"
1537+
ItemsSourceSelector = "{StaticResource itemSourceSelector}"
1538+
MappingName = "ShipCity"
1539+
ValueMember = "ShipCity">
1540+
<syncfusion:DataGridMultiColumnComboBoxColumn.Columns>
1541+
<syncfusion:DataGridTextColumn HeaderText = "Ship City" MappingName = "ShipCity" />
1542+
<syncfusion:DataGridCheckBoxColumn HeaderText = "Is Primary" MappingName = "IsPrimary" />
1543+
</syncfusion:DataGridMultiColumnComboBoxColumn.Columns>
1544+
</syncfusion:DataGridMultiColumnComboBoxColumn>
1545+
<syncfusion:DataGridTextColumn MappingName = "ShipCountry" HeaderText = "Ship Country"/>
1546+
</syncfusion:SfDataGrid.Columns>
1547+
</syncfusion:SfDataGrid>
1548+
1549+
{% endhighlight %}
1550+
1551+
{% highlight c# %}
1552+
1553+
internal class ItemsSourceSelector : IItemsSourceSelector
1554+
{
1555+
public IEnumerable GetItemsSource(object record, object dataContext)
1556+
{
1557+
if (record == null)
1558+
return null;
1559+
1560+
var orderinfo = record as Orders;
1561+
var countryName = orderinfo.ShipCountry;
1562+
1563+
var viewModel = dataContext as OrdersViewModel;
1564+
1565+
//Returns ShipCity collection based on ShipCountry.
1566+
if (viewModel.ShipCityItemsSources.ContainsKey(countryName))
1567+
{
1568+
ObservableCollection<ShipCityEntry> shipCities = null;
1569+
viewModel.ShipCityItemsSources.TryGetValue(countryName, out shipCities);
1570+
return shipCities.ToList();
1571+
}
1572+
1573+
return null;
1574+
}
1575+
}
1576+
1577+
{% endhighlight %}
1578+
1579+
{% endtabs %}
1580+
1581+
<img alt="DataGridMultiColumnComboBox column with ItemsSourceSelector .NET MAUI DataGrid" src="Images\column-types\maui-datagrid-MultiColumn-ComboBox-column-itemsourceselector.png" width="404"/>
1582+
1583+
<img alt="DataGridMultiColumnComboBox column with ItemsSourceSelector .NET MAUI DataGrid" src="Images\column-types\maui-datagrid-MultiColumn-ComboBox-column-itemsourceselector2.png" width="404"/>
1584+
1585+
You can download the sample from the following link: (Sample)[https://github.com/SyncfusionExamples/How-to-load-different-items-for-each-row-in-MultiColumn-ComboBox-Column-in-.NET-MAUI-SfDataGrid].
1586+
14211587
## Row header
14221588

14231589
The row header is a type of column that is placed as the first cell of each row and remains frozen. To enable the row header, set [SfDataGrid.ShowRowHeader](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.SfDataGrid.html#Syncfusion_Maui_DataGrid_SfDataGrid_ShowRowHeader) to `true` Additionally, the `SfDataGrid` allows you to customize the row header width using the [SfDataGrid.RowHeaderWidth](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.SfDataGrid.html#Syncfusion_Maui_DataGrid_SfDataGrid_RowHeaderWidth) property. The default value is `30.`
18.2 KB
Loading
7.55 KB
Loading
8.04 KB
Loading
9.12 KB
Loading

0 commit comments

Comments
 (0)