Grid: Using nested grids with nested objects #835
-
Hi there, I'm trying to use Grids to display a nested object. For example, given the following classes: public class Employee
{
string Name { get; set; }
List<TaskInfo> TaskList { get; set; }
}
public class TaskInfo
{
string Name { get; set; }
} For the above example, it would make sense to display a grid of employees names, and then a nested grid of each employee's list of tasks. How would I actually go about doing this? The example in the docs here does not show when using a nested object, because it reuses the same object (which is not a very common use case for nested grids imo) The problem is that within the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I've resolved this question. The comment from here #784 (reply in thread) was the answer, but could be explained a bit better For the example above, the GridDetailView should look like this: <GridDetailView TItem="Employee" Context="employee">
<Grid TItem="TaskInfo"
Class="table table-hover border-top"
DataProvider="(request) => TaskDataProvider(request, employee)">
<GridColumns>
<GridColumn TItem="TaskInfo" Context="task" HeaderText="Field" PropertyName="Field">
@task.Name
</GridColumn>
</GridColumns>
</Grid>
</GridDetailView> private async Task<GridDataProviderResult<TaskInfo>> TaskDataProvider(GridDataProviderRequest<TaskInfo> request, Employee employee)
{
return await Task.FromResult(request.ApplyTo(employee.TaskList));
} |
Beta Was this translation helpful? Give feedback.
I've resolved this question. The comment from here #784 (reply in thread) was the answer, but could be explained a bit better
For the example above, the GridDetailView should look like this:
@code