|
<SfGrid DataSource="@Employees" Height="315px">
<GridEvents RowDataBound="RowDataBound" TValue="EmployeeData"></GridEvents>
<GridTemplates>
<DetailTemplate>
@{
var employee = (context as EmployeeData);
<SfGrid DataSource="@Orders" Query="@(new Query().Where("EmployeeID", "equal", employee.EmployeeID))">
<GridColumns>
</GridColumns>
</SfGrid>
}
</DetailTemplate>
</GridTemplates>
<GridColumns>
<GridColumn Field=@nameof(EmployeeData.FirstName) HeaderText="First Name" Width="110"> </GridColumn>
</GridColumns>
</SfGrid>
<style>
/*to disbale the mouse actions*/
.e-detail-disable .e-detailrowcollapse {
pointer-events: none;
}
/*if required hide the icons*/
.e-detail-disable .e-detailrowcollapse .e-icon-grightarrow {
visibility: hidden;
}
</style>
@code{
public void RowDataBound(RowDataBoundEventArgs<EmployeeData> Args) // will be triggered when row is created
{
if (Orders.Where(x => x.EmployeeID == Args.Data.EmployeeID).ToList().Count == 0) // check condition here whether the detail grid has records
{
Args.Row.AddClass(new string[] { "e-detail-disable" });
}
}
|