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

EJ2.Grids set up stacked header column as foreign key column

When making a foreign key column in a grid i do this:

<e-grid-column field="JobDescription" headerText="Job Description" foreignKeyField="ListMemberId" foreignKeyValue="Description" dataSource="ViewBag.jobDescriptions" width="250"></e-grid-column>

and it works great.

when making a stacked header grid column i am using this method

@{

 var stackedHeader4 = new List<Syncfusion.EJ2.Grids.GridColumn>() {

            new Syncfusion.EJ2.Grids.GridColumn { Field = "LeadFound", HeaderText = "Lead Found", EditType="BooleanEdit", Width="140"},

...

}

and it works great.

but I can't seem to get a foreign key in my stacked header column using ViewBag as a source, as I don't seem to have the right syntax.

            new Syncfusion.EJ2.Grids.GridColumn { Field = "RestoreType", HeaderText = "Restore Type", ForeignKeyField="ListMemberId", ForeignKeyValue="Description", DataSource=@ViewBag.restoreType, Width="200"},

and it fails miserably.

anyone know how to do this?



2 Replies 1 reply marked as answer

JL Jason Leach December 10, 2022 04:01 PM UTC

Solved it myself! (yay)

the solution is to use a ViewData["thing"] not VIewBag.

new Syncfusion.EJ2.Grids.GridColumn { Field = "RestoreType", HeaderText = "Restore Type", ForeignKeyField="ListMemberId", ForeignKeyValue="Description", DataSource=ViewData["restoreType"], Width="200"}


Marked as answer

SG Suganya Gopinath Syncfusion Team December 11, 2022 06:56 AM UTC

Hi Jason,

Thanks for sharing the solution that you have tried. This will be helpful. 

Please get back to us for further assistance. We are marking this thread as solved. 

Regards,

Suganya Gopinath.



Loader.
Live Chat Icon For mobile
Up arrow icon