We want the ability to have a hierarchical grid that fetches the sub-grid (detail) data on demand (when row is expanded) . Our API returns Lists of objects. We are not using SfDataManager. Upon expanding a row, method DetailDataBoundHandler is called and properly sets the UserApps collection from the returned list of objects. However, the expanded row shows no data. What is the proper way of doing this?
Attachment: code_db4dfed7.zip
Just change the ZIP extension to TXT and you'll be able to view my code.
Renjith,
I figured out my issue. In the DetailTemplate, I did NOT have my <GridColumn> surrounded by <GridColumns>. Now everything works. However, I'm facing another issue. Although DetailDataBoundHandler, is properly retrieving the detailed data for each row, when I expand a row AFTER I have expanded another row, the previous rows detailed data is showing up in the current row. However, when I collapse and then re-expand the current row, the proper data is shown. How to I fix this?
Thanks,
Dave
|
<GridTemplates>
<DetailTemplate>
@{
var Data = (context as EmployeeData);
Orders = _ForecastService.GetApps(Data.EmployeeID).GetAwaiter().GetResult();
<SfGrid DataSource="@Orders">
<GridColumns>
</GridColumns>
</SfGrid>
}
</DetailTemplate>
</GridTemplates>
|
Renjith,
Thank for your response. I implemented what you suggested and I get an error :
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Cannot wait on monitors on this runtime.
System.PlatformNotSupportedException: Cannot wait on monitors on this runtime.
Error occurs on the bold line below:
@{
InfUser infUser = (context as InfUser);
UserApps = _authService.GetApps(infUser.ID).GetAwaiter().GetResult();
<SfGrid....
}
Thanks
Renjith,
Attached are (2) files. One representing the grid, the other file contains our service code. The service code makes calls to our API via HttpClient. I think the big difference between our code and your example code is that we are calling an asynchronous API. Even when using GetAwaiter().GetResult() in the method GetAppRoles(int id), we still see the error.
Thanks
|
<GridTemplates>
<DetailTemplate>
@{
EmployeeData Data = (context as EmployeeData);
<SfGrid TValue="Order" Query=@(new Query().AddParams("DetailData",Data.EmployeeID))>
<SfDataManager AdaptorInstance="@typeof(CustomAdaptor)" Adaptor="Adaptors.CustomAdaptor"></SfDataManager>
<GridColumns>
</GridColumns>
</SfGrid>
}
</DetailTemplate>
</GridTemplates>
@code{
public class CustomAdaptor : DataAdaptor
{
public WeatherForecastService _ForecastService { get; set; }
public CustomAdaptor(WeatherForecastService ForecastService)
{
_ForecastService = ForecastService;
}
// Performs data Read operation
public override async Task<object> ReadAsync(DataManagerRequest dm, string key = null)
{
string val = dm.Params["DetailData"].ToString();
IEnumerable<Order> DataSource = await _ForecastService.GetApps(Convert.ToInt32(val));
...
}
}
...
} |
Renjith,
Works perfectly! Thanks for all your help :)
I've successfully implemented a CustomAdapter (see above) for my child grid. I've also implemented editing, and have OnActionBegin() & OnActionComplete() methods defined for the child grid. How would I "refresh" the child grid following an edit. After a "save", it seems that the ReadAsync() method of the CustomAdapter class is called BEFORE the OnActionComplete() method (this is where I'm retrieving the updated child row in our DB). I'm doing the actual update of our the child grid row in our DB in the OnActionBegin() method.
Thanks