We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

how to bind MultiColumnDropdownControl in DataGrid

Hi,

I want to bind MultiColumnDropdownControl in DataGrid and upon selectionChange in MultiColumnDropdown i want the columns in DataGrid to be updated. Below is code i have tried but it doesn't work out

  <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






3 Replies

JG Jai Ganesh S Syncfusion Team August 6, 2013 01:01 PM UTC

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



NO noor August 16, 2013 06:51 AM UTC

Hi Ganesh,

thanks for the reply, it solved my problem, though i need to do little tweaks.

thanks
-noor


JG Jai Ganesh S Syncfusion Team August 16, 2013 08:07 AM UTC

Hi Noor,

 

Thanks for your update.

 

Please let us know if you have any queries.

 

Thank you,

Jai Ganesh S


Loader.
Live Chat Icon For mobile
Up arrow icon