Hi Asdf,
Thanks for contacting Syncfusion support.
Query: “I want to provide detail template of datagrid control only in specific row. Is there a way?”
We have analyzed your query and we suggest you to achieve your requirement using RowDataBound event of Grid. RowDataBound event will be triggered when row is created. We suggest you to add specific style to particular row to hide the detail template based on your condition.
|
<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>
</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" });
}
}
|
For your convenience we have prepared a sample which can be downloaded from below
Refer our UG documentation for your reference
Please get back to us if you have further queries.
Regards,
Vignesh Natarajan