Binding Dropdown List to another database

I've been searching for information on what I'm doing wrong with this GridForeignColumn and I'm hoping you can let me know.



When I don't set this column to a GridForeignColumn my table works fine, but it displays the foreign key and I'm wanting a link to the other table which contains the Phase name.

I've set up a custom adaptor that is controlling the main grid, but I'm following the foreign key column section of the documentation so I created a second adaptor to read the second table since I won't be updating that table from this grid.

However, when I go to the page I'm getting an unhandled exception error that the source value cannot be null


and the table won't generate:






3 Replies

RS Renjith Singh Rajendran Syncfusion Team May 4, 2020 01:09 PM UTC

Hi Brandon, 

Thanks for contacting Syncfusion support. 

We suggest you to ensure to return the resultant DataSource for the ForeignKeyColumn from CustomAdaptor Read method as a List to overcome the problem you are facing. We have prepared a sample based on this scenario. Please download the sample from the link below, 
 
Please refer the codes below, 

 
        <GridForeignColumn TValue="EmployeeData" Field=@nameof(Order.EmployeeID) HeaderText="Employee Name" ForeignKeyValue="FirstName" Width="150"> 
            <Syncfusion.Blazor.Data.SfDataManager AdaptorInstance="@typeof(CustomAdaptor1)" Adaptor="Adaptors.CustomAdaptor"></Syncfusion.Blazor.Data.SfDataManager> 
        </GridForeignColumn> 
 
    public class CustomAdaptor1 : DataAdaptor 
    { 
        // Performs data Read operation 
        public override object Read(DataManagerRequest dm, string key = null) 
        { 
            IEnumerable<EmployeeData> DataSource = Employees; 
            ... 
           return dm.RequiresCounts ? new DataResult() { Result = DataSource, Count = count } : (object)DataSource.ToList(); 
        } 
    } 


Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 



BS Brandon Schafer May 5, 2020 02:45 AM UTC

Hi Renjith,

Thanks for the reply. I did some additional digging and downloaded your sample file to verify my custom adaptors were aligned with yours. I did finally get it to work, though what I had to do was remove the stacked header component of my original datagrid. I had a stacked header wrapping all other columns (per the sample here) to represent a title since I have multiple datagrids on one page. By trying to eliminate all variables I removed these and the datagrid began working as expected. Then I tested this in your sample datagrid by wrapping the columns in a "title" column and verified that I could reproduce the error.



I'm just going to include a header title above the datagrid rather than incorporate it into the grid itself, but I thought I'd let you know just in case this is a potential bug.

Thanks,
Brandon


RS Renjith Singh Rajendran Syncfusion Team May 6, 2020 02:53 PM UTC

Hi Brandon, 

Thanks for your update. 

We have confirmed this as a defect and logged a defect report for the same. Thank you for taking the time to report this issue “Problem with displaying ForeignKeyColumn in a StackedHeader Grid” and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle ) and including the defect fix in our upcoming bi-weekly release which is expected to be rolled out in the month of May 2020.  

You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.  

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 


Loader.
Up arrow icon