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

The GridForeignColumn will not show the drop down information during edit / add mode.

The EntRelId will show the initial value when the grid is displayed but will not show the drop data list with the data.   The 2nd GridForeign column will show the drop down data but the field EntId matches the foreign key table.  I did a simple foreach to display there is data in  the foreignDatasource="@ents"

Video and code attached.   Thanks for you help.


Snippet
<GridForeignColumn Field="@nameof(EntRelsModel.EntRelId)" 
                    TValue="Ent"
                    HeaderText="Related Name"
                    ForeignDataSource="@ents"
                    ForeignKeyField="EntId"
                    ForeignKeyValue="FullName"
                    Width="150px"
                    Visible="relatedVisible">
</GridForeignColumn>    
<GridForeignColumn Field="@nameof(EntRelsModel.EntId)"
                    TValue="Ent"
                    HeaderText="Student Name"
                    ForeignDataSource="@ents"
                    ForeignKeyField="EntId"
                    ForeignKeyValue="FullName"
                    Width="150px"
                    Visible="studentVisible">
</GridForeignColumn>    

Attachment: Issue_no_drop_down_2a99649f.zip

3 Replies

MS Monisha Saravanan Syncfusion Team February 15, 2023 09:29 AM UTC


Hi Larry,


After reviewing your code, we have identified that the first foreign key column "Field" (EntRelId) is not present in the foreign key table, which is causing the reported issue.


To resolve this, we recommend ensuring that the "Field" is present in the foreign key table. So based on the field it will generate the Foreignkey Datasource.


Kindly check the below attached code snippet.


<GridForeignColumn Field="@nameof(EntRelsModel.EntRelId)" // This field is not present in foreignkey table

                                TValue="Ent"

                                HeaderText="Related Name"

                                ForeignDataSource="@ents"

                                ForeignKeyField="EntId"

                                ForeignKeyValue="FullName"

                                Width="150px"

                                Visible="relatedVisible">

            </GridForeignColumn>   


Please let us know if you have any concerns.


Regards,

Monisha



LA Larry February 16, 2023 01:16 AM UTC

Hi, I understand the Foreign key is not required based on this response in another thread and I had it working like this with another GridForeignColumn definiton.

https://www.syncfusion.com/forums/165983/different-field-key-name-and-foreignfield-key-name-in-gridforeigncolumn


I figured out my problem.    The drop down on a GridForeignColumn would not work if the same field defined in a Grid Column and GridForeignColumn as shown below.    Once I removed the GridColumn definition the dropdown worked fine.

thanks for your response and overall support is amazing.


Snippet
<GridColumn HeaderText="Related ID" IsPrimaryKey=true Field="@nameof(EntRelsModel.EntRelId)" Width="100px"></GridColumn> 
Snippet
<GridForeignColumn Field="@nameof(EntRelsModel.EntRelId)"
                    TValue="Ent"
                    HeaderText="Student Name"
                    ForeignDataSource="ents"
                    ForeignKeyField="EntId"
                    ForeignKeyValue="FullName"
                    Width="150px"
                    Visible="@relatedVisible">
 </GridForeignColumn>


MS Monisha Saravanan Syncfusion Team February 16, 2023 11:24 AM UTC

Hi Larry,


Welcome. We are glad to hear that the reported issue has been resolved. Kindly get back to us if you have further queries. As always we will be happy to help you.


Loader.
Live Chat Icon For mobile
Up arrow icon