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

Question about hierarchical binding

Two things, actually:

1. The documentation says to add the .QueryString property to indicate the name of the master's ID field. However, it makes no mention of setting .ForeignKey to the field name in the child datasource. I deduced that it might be necessary, but it would have been nice to see it in the docs.

2. When adding a child record, it shows up in the CrudResult handler without it's foreign key set. There isn't any mention in the "param" parameter of what that value should be. Is it maybe being passed to a property that I don't have defined? If not, how do I populate the foreign key field so that it will show up in the child grid properly (as well as satisfying the table's foreign key constraint in the database)?

3 Replies

RU Ragavee U S Syncfusion Team December 2, 2016 12:33 PM UTC

Hi Brian, 

Query #1: The documentation says to add the .QueryString property to indicate the name of the master's ID field. However, it makes no mention of setting .ForeignKey to the field name in the child datasource. 

We suspect that you are mentioning about the ForeignKeyField property of the Child Grid which is used when the mapping field name differs in the parent and child table. Considering this, we have created an improvement task to include the details on this property. It will be refreshed online as early as possible. 

Query #2:  how do I populate the foreign key field so that it will show up in the child grid properly 

We suggest you to define the foreign key column of the child grid to get the corresponding details while editing and saving. We can set the visible property of the corresponding column as “false” if we don’t want the column to be displayed in grid. 


Even if the visible property is set as false, the corresponding column values will be obtained in the argument when updating the record.  

Regards, 
Ragavee U S. 



RB R Brian Lindahl December 2, 2016 02:27 PM UTC

I have this:

    .ChildGrid(child =>
    {
        child
        .Datasource(ds => ds.URL("/RolesAdmin/LinksDataSource").CrudURL("/RolesAdmin/LinksCrudResult").Adaptor(AdaptorType.UrlAdaptor))
        .QueryString("Id")
        .ForeignKeyField("RoleID")
...
        .Columns(col =>
        {
            col.Field("RoleLinkID").HeaderText("ID").IsPrimaryKey(true).IsIdentity(true).Visible(false).Add();
            col.Field("RoleID").Visible(false).Add();
            col.Field("LinkName").HeaderText("Link name").Add();

however, in the CRUD handler, the RoleID property is null. I was expecting from your instructions that the parent row's "Id" field would be copied into the child grid's "RoleID" when a new record is inserted in the child grid.


MS Mani Sankar Durai Syncfusion Team December 5, 2016 11:40 AM UTC

Hi Brian, 


A support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates.  
 
 
 
Regards, 
Manisankar Durai. 


Loader.
Live Chat Icon For mobile
Up arrow icon