BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
<grid:SfDataGrid Grid.Row="1" ItemsSource="{Binding Items,Mode=TwoWay}" HorizontalAlignment="Stretch" AutoGenerateColumns="False" AllowEditing="True" AllowFiltering="True" AllowResizingColumns="True"> <grid:SfDataGrid.Columns> <grid:GridTemplateColumn HeaderText="Item Number" MappingName="ItemNumber"> <grid:GridTemplateColumn.CellTemplate> <DataTemplate> <grid:SfMultiColumnDropDownControl ItemsSource="{Binding Items,Mode=TwoWay}" DisplayMember="ItemNumber" SelectedItem="{Binding Item,Mode=TwoWay}" x:Name="ItemNo" ValueMember="ItemNumber" AutoGenerateColumns="False"> <grid:SfMultiColumnDropDownControl.Columns> <grid:GridTextColumn MappingName="ItemNumber"/> <grid:GridTextColumn MappingName="Product"/> <grid:GridTextColumn MappingName="ProductName"/> </grid:SfMultiColumnDropDownControl.Columns> </grid:SfMultiColumnDropDownControl> </DataTemplate> </grid:GridTemplateColumn.CellTemplate> </grid:GridTemplateColumn> <grid:GridTextColumn MappingName="ProductName" HeaderText="Product Name" DisplayBinding="{Binding ElementName=ItemNo,Path=SelectedItem.ProductName}"/> <!--// DisplayBinding="{Binding ElementName=ItemNo,Path=SelectedItem.ProductName,Mode=TwoWay}"/>--> <grid:GridTextColumn HeaderText="Procurement Category" MappingName="ProcurementCategory"/><!--ValueBinding="{Binding ElementName=ItemNo,Path=SelectedItem.ProcurementCategory}"/>--> <grid:GridTextColumn HeaderText="Quantity" MappingName="Quantity" AllowEditing="False" /> <grid:GridTextColumn HeaderText="Unit Price" MappingName="UnitPrice" AllowEditing="False" DisplayBinding="{Binding ElementName=ItemNo,Path=SelectedItem.UnitPrice,Mode=TwoWay}"/> </grid:SfDataGrid.Columns> </grid:SfDataGrid>
I have also tried doing
[C#]
void syncgrid_CurrentCellEndEdit(object sender,CurrentCellEndEditEventArgs args)
{
var rowIndex =this.syncgrid.ResolveToRecordIndex(args.RowColumnIndex.RowIndex);
var record = (this.syncgrid.View.Records[rowIndex]).Data asProductInfo;
//Check to see if the user is editing the discount column.
if (args.RowColumnIndex.ColumnIndex == 4)
{
//Computes the price from the discount property.
if (record != null)
record.Price = record.Price - record.Discount;
}
}
But i don't find any method on SfDataGrid object with name ResolveToRecordIndex. Do i need to add namespace if it is an extension method.
If you could provide me a working sample i would be very gratefull to you
thanks
noor
Hi
Noor,
Thanks
for contacting syncfusion support.
Please
find the response for your queries
below,
Query 1:
Binding
between DataTemplateElement and GridColumn will not work. Intead of using
GridTemplateColumn you can use
GridMultiColumnDropDownList column. By using the CurrentCell Validated event of
SfDataGrid you can update the other columns based on MultiColumnDropDown
control selected value.
We
have created a simple sample based on your requirement and please download the
sample from following link,
Sample: SampleGrid.zip
Note: When current cell losses focus CurrentCellValidated
event will be triggered.
Query 2:
To
use the ResolveToRecordIndex, you have to include the “Syncfusion.UI.Xaml.Grid
namespace in your application.
Please
let us know if you need further assistance.
Thank you,
Jai Ganesh S
Hi Noor,
Thanks for your update.
Please let us know if you have any queries.
Thank you,
Jai Ganesh S