| public class MySelectionController : GridSelectionController { public MySelectionController(SfDataGrid dataGrid) : base(dataGrid) { } protected override void ProcessSelectedIndexChanged(SelectionPropertyChangedHandlerArgs handle) { base.ProcessSelectedIndexChanged(handle); int newIndex = (int)handle.NewValue; int oldIndex = (int)handle.OldValue; if (newIndex >= 0) { Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() => { this.DataGrid.ExpandDetailsViewAt(newIndex); }), DispatcherPriority.ApplicationIdle); } if (oldIndex >= 0) { this.DataGrid.CollapseDetailsViewAt(oldIndex); } } } |
|
<syncfusion:SfDataGrid Name="dataGrid"
AutoGenerateColumns="False"
ItemsSource="{Binding OrderList}"
ColumnSizer="Star"
AllowDeleting="True"
AllowFiltering="True"
AllowSorting="True"
AllowGrouping="True"
ShowGroupDropArea="True"
RowHeight="40">
<syncfusion:SfDataGrid.DetailsViewDefinition>
<syncfusion:TemplateViewDefinition HeightMode="Auto" RowTemplate="{StaticResource DetailsViewTemplate}" NavigationMode="ExcludeTemplateRow"/>
</syncfusion:SfDataGrid.DetailsViewDefinition>
<syncfusion:SfDataGrid.Columns>
<syncfusion:GridTextColumn HeaderText="Order ID" MappingName="OrderID" />
<syncfusion:GridTextColumn HeaderText="Customer ID" MappingName="CustomerID"/>
<syncfusion:GridComboBoxColumn ItemsSource="{Binding Path=ComboBoxItemsSource, Source={StaticResource viewmodel}}"
MappingName="ProductName" />
<syncfusion:GridNumericColumn HeaderText="Quantity"
MappingName="Quantity"
SetCellBoundValue="True"
NumberDecimalDigits="0"/>
<syncfusion:GridCurrencyColumn HeaderText="Freight" MappingName="Freight" DisplayBinding="{Binding Path=Freight}"/>
<syncfusion:GridCheckBoxColumn MappingName="IsClosed" />
</syncfusion:SfDataGrid.Columns>
</syncfusion:SfDataGrid> |