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

Merge two columns, one with a foreign key

Hello, I have two models in Grid. One with a foreign key. What I want to do is combine the values of a field from the first pattern in a column and a field from the model with a foreign key into one arm. In other words, if the value is "A" in the relevant column in the first model, and the value is "B" in the model with a foreign key, it will appear as "AB" in this column. How can I do?


3 Replies

PS Prathap Senthil Syncfusion Team April 17, 2023 04:48 PM UTC

Hi Gencer,

Regarding your query about displaying "AB" in a column when the value is "A" in the relevant column in the first model and "B" in the model with a foreign key, you can achieve this using the Template column feature. Please refer to the attached code snippet and sample for your reference. Please get back to us if you face any difficulties.


<GridColumn HeaderText="ABcolumn" Width="120">

            <Template>

               @{

                    var a = (context as Order);

                    var data = Employees.Where(x => x.EmployeeID ==a.EmployeeID).ToList();

                    var b = data[0].FirstName;

                    @a.EmployeeID;

                    @b;

               }

            </Template>

        </GridColumn>




Regards,
Prathap S


Attachment: BlazorApp1_fadd247a.zip


GE Gencer April 17, 2023 09:33 PM UTC

Thank you very much. You are amazing!



PS Prathap Senthil Syncfusion Team April 18, 2023 05:28 AM UTC


Thank you for letting us know that the provided solution was helpful. We are glad to hear that it has been resolved. We will now close this thread.

Please get back to us if you have any further queries.


Loader.
Live Chat Icon For mobile
Up arrow icon