How to make a lookup Cell with autogenerated columns?

Dear Support Team

I would like to make a lookup Column, with autogenerated columns. How can I achieve this. Can I use a template selecter with autogenerated columns? Or do I need to make a specific behaviour class. Which one I do have to overwrite?


This would be an example:



br Patrick


5 Replies

VS Vijayarasan Sivanandham Syncfusion Team July 12, 2021 02:55 PM UTC

Hi Patrick,

Thank you for contacting Syncfusion Support.

We are little unclear with your scenario. Based on provided information we suspect that your requirement is display the all cell value of column and filter that value in SfDataGrid.

Your requirement can be achieved by using FilterRow in SfDataGrid. For more information related to FilterRow, please refer the user guide documentation,

UG Link: https://help.syncfusion.com/wpf/datagrid/filterrow
 
If we misunderstood your requirement, can you please provide the more information related to your query?

Can you please share us below things?
       
       
        1. Provide more details about your scenario with illustrations?
                2. Can you please share your exact requirement?
 
It will be helpful for us to check on it and provide you the solution at the earliest.

Regards,
Vijayarasan S
 



PA Patrick July 12, 2021 05:04 PM UTC

Dear Vijayarasan


Sorry may be my question was not clear enough.


I have a DataSet with Relatated Tables. I would like to show the related Row in a ComboBoxCell.


Let's say in the DataGrid is "Table A" shown. "Table A" has a column with "Table B.ID". Like in the picture in the original post, i would like show another Value from "Table B" in the ID Column. So create a lookup, from Table A to Table B.


Table A:

Team IDTeam NameCyclist ID
001Movistar001
001Movistar002


Table B:

Cyclist IDCyclist Name
001John Doe
002Max Willard


DataGrid what I like to achieve

Team IDTeam NameCyclist
001MovistarLookup to Table B and show Cyclist Row with ComboBox
001Movistar Lookup to Table B and show Cyclist Row with ComboBox


Hope this makes it clear.



VS Vijayarasan Sivanandham Syncfusion Team July 13, 2021 03:30 PM UTC

Hi Patrick,

Thanks for the update.

Your requirement can be achieved by using GridMutiColumnDropDownList in SfDataGrid. For more information related to GridMutiColumnDropDownList, please refer the below UG link,

UG Link: https://help.syncfusion.com/wpf/datagrid/column-types#gridmulticolumndropdownlist

Please let us know if you have any concerns in this. 
Regards,
Vijayarasan S 



PA Patrick July 13, 2021 04:04 PM UTC

Thank you. Yes I have seen this possiblity with GridMultiColumnDropDownList. But as I can see, the sample on the help page, does not use "Autogenerate Columns". 

How can I achieve this with Autogenerate columns? Because I change the ItemSource of the dataGrid often.


Practically I would like to check before the cell is drawed, if the row/column has a child row and if yes, then use the MultiColumn.


Which method I have to override to achieve this?


Thank you for your Feedback.



VS Vijayarasan Sivanandham Syncfusion Team July 14, 2021 06:52 AM UTC

Hi Patrick,

Thanks for the update.

You can change the Column type by using AutoGeneratingColumn event in SfDataGrid. Please refer the below code snippet for your reference, 
//trigger the AutoGenenerate column event 
sfDataGrid.AutoGeneratingColumn += sfDataGrid_AutoGeneratingColumn; 
 
private void sfDataGrid_AutoGeneratingColumn(object sender, AutoGeneratingColumnArgs e) 
{ 
            //check the column  
            if (e.Column.MappingName == "ShipCity") 
            { 
                //change the Column type GridTextColumn into GridMultiColumnDropDownList in SfDataGrid 
                if (e.Column is GridTextColumn) 
                { 
                    //Change the column type in AutoGenerated case 
                    e.Column = new GridMultiColumnDropDownList() { ItemsSource = viewModel.ShipCountry, MappingName = "ShipCity", HeaderText = "Ship City", DisplayMember = "ShipCityName", ValueMember = "ShipCityName" };                    
                } 
            } 
} 
Please let us know if you have any concerns in this.

Regards,
Vijayarasan S 


Loader.
Up arrow icon