Hi Jim,
Greetings from syncfusion support.
We have validated you query and found that you need to expand only the lastly clicked expand/collapse icon. You can achieve your requirement by using the Microsoft JSInterop and binding the javascript click event to check the current target and then invoking the DetailExpandCollapseRow method of grid. Please find the below code snippet and the sample for your reference.
Index.razor
|
<SfGrid @ref="Grid" ID="Grid" DataSource="@Employees">
<GridEvents DetailDataBound="DetailDataBound" DataBound="DataBound" TValue="EmployeeData"></GridEvents>
..
..
</SfGrid>
@code{
public bool firstrender { get; set; } = true;
public async Task DataBound()
{
if (firstrender)
{
var dotNetReference = DotNetObjectReference.Create(this);
await Runtime.InvokeAsync<string>("detail", dotNetReference);
firstrender = false;
}
}
public async Task DetailDataBound(DetailDataBoundEventArgs<EmployeeData> args)
{
if (target != null)
{
if (target == args.Data)
{
return;
}
await Grid.DetailExpandCollapseRow(target);
}
target = args.Data;
}
[JSInvokable("DetailCollapse")]
public void DetailRowCollapse()
{
target = null;
}
} |
Detailexpand.js
|
var dotnetInstance;
function detail(dotnet) {
dotnetInstance = dotnet; // dotnet instance to invoke C# method from JS
}
document.addEventListener('click', function (args) {
if (args.target.classList.contains("e-dtdiagonaldown") || args.target.classList.contains("e-detailrowexpand")) {
dotnetInstance.invokeMethodAsync('DetailCollapse'); // call C# method from javascript function
}
}) |
Host.cshtml
|
<head>
..
<script src="~/detailexpand.js"></script>
..
</head> |
Please get back to us if you need further assistance.
Regards,
Jeevakanth SP.