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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

how to bind MultiColumnDropdownControl in DataGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

110398 Aug 1,2013 09:12 AM UTC Aug 16,2013 08:07 AM UTC WinRT 3
loading
Tags: SfDataGrid
noor
Asked On August 1, 2013 09:12 AM UTC

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






Jai Ganesh S [Syncfusion]
Replied On 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


noor
Replied On 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

Jai Ganesh S [Syncfusion]
Replied On 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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;