<syncfusion:SfDataGrid x:Name="DataGrid" ItemsSource="{Binding Delivery}" AllowGrouping="True" AllowDeleting="True" SelectionUnit="Row" EditTrigger="OnTap" AutoGenerateColumns="False" ShowGroupDropArea="True" AllowFiltering="True" AllowEditing="True" NewItemPlaceholderPosition="AtBeginning" ShowRowHeader="True" AddNewRowPosition="Top"> <syncfusion:SfDataGrid.Columns> <syncfusion:GridComboBoxColumn HeaderText="Material" SelectedValuePath="Description" DisplayMemberPath="Name" ItemsSource="{Binding MaterialParts}" MappingName="Description"> </syncfusion:GridComboBoxColumn> <syncfusion:GridTextColumn HeaderText="Description" IsReadOnly="True" MappingName="Description" /> <syncfusion:GridTextColumn HeaderText="Quantity" MappingName="Qty" /> </syncfusion:SfDataGrid.Columns> </syncfusion:SfDataGrid>
|
private void SfDataGrid_CurrentCellDropDownSelectionChanged(object sender, CurrentCellDropDownSelectionChangedEventArgs e)
{
var recordindex = this.sfDataGrid.ResolveToRecordIndex(e.RowColumnIndex.RowIndex);
var record = this.sfDataGrid.View.Records[recordindex];
var data = record.Data as Materials;
data.Description = (e.SelectedItem as Materials).Description;
data.Quantity = (e.SelectedItem as Materials).Quantity;
}
<syncfusion:SfDataGrid x:Name="sfDataGrid"
AllowEditing="True"
ItemsSource="{Binding Path=MaterialCollection}"
CurrentCellDropDownSelectionChanged="SfDataGrid_CurrentCellDropDownSelectionChanged"
AutoGenerateColumns="False">
<syncfusion:SfDataGrid.Columns>
<syncfusion:GridComboBoxColumn MappingName="Name" ItemsSource="{Binding MaterialCollection}" SelectedValuePath="Name" DisplayMemberPath="Name" />
<syncfusion:GridTextColumn MappingName="Description"/>
<syncfusion:GridTextColumn MappingName="Quantity" />
</syncfusion:SfDataGrid.Columns>
</syncfusion:SfDataGrid> |
|
private void SfDataGrid_CurrentCellDropDownSelectionChanged(object sender, CurrentCellDropDownSelectionChangedEventArgs e)
{
if (this.sfDataGrid.IsAddNewIndex(e.RowColumnIndex.RowIndex))
{
data.Description = (e.SelectedItem as Materials).Description;
data.Quantity = (e.SelectedItem as Materials).Quantity;
}
else
{
var recordindex = this.sfDataGrid.ResolveToRecordIndex(e.RowColumnIndex.RowIndex);
var record = this.sfDataGrid.View.Records[recordindex];
var rowdata = record.Data as Materials;
rowdata.Description = (e.SelectedItem as Materials).Description;
rowdata.Quantity = (e.SelectedItem as Materials).Quantity;
}
}
private void SfDataGrid_AddNewRowInitiating(object sender, AddNewRowInitiatingEventArgs e)
{
data = e.NewObject as Materials;
} |