BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hi,
its not mentioned how to hide/show the detail row for treegrid - we would like to achieve the same behavior as in datagrid ( but with hierarchical data - thats why we use treegrid instead of datagrid )
#table-id .e-detailrow {
display: none;
}
#table-id .e-row[aria-selected="true"] + .e-detailrow {
display: table-row;
}
edit: moved drag&drop problems to bug report ticket
Hi Christoph,
Before proceeding this, we need some more additional details about the requirement. Share us the following details.
Regards,
Farveen sulthana T
Hi Christoph,
Further analyzing, we couldn’t achieve the exact functionality that Grid component possess. By default TreeGrid display the detail Template in Expanded state only. So it is not feasible to show/hide detail Template for specific row.
As a workaround, we have implemented a solution using Microsoft JsInterop and which allows to show the detail row using external CSS with Expanding Event of the TreeGrid. Initially we can render the TreeGrid by setting EnableCollapseAll property and hide the Detailrow by setting display:none property. Based on this you can handle your own customization as per your convenience.
Refer to the code below:-
@inject IJSRuntime JSRuntime
<SfTreeGrid @ref="@reference" TValue="SelfReferenceData" DataSource="@TreeData" Height="400" EnableCollapseAll="true" IdMapping="TaskId" ParentIdMapping="ParentId" TreeColumnIndex="1"> TreeGridEvents Expanding="ExpandingHandler" Collapsing="CollapsingHandler" TValue="Employee"></TreeGridEvents>
. . . </SfTreeGrid>
@code{ private IEnumerable<Employee> TreeGridData { get; set; } protected override void OnInitialized() { this.TreeGridData = Employee.GetTemplateData(); } public async Task ExpandingHandler(RowExpandingEventArgs<Employee> args) { // Here you can customize your code await JSRuntime.InvokeAsync<object>("TreeGridfile"); } }
TreeGridfile.js function TreeGridfile() { var rows = document.getElementById("TreeGrid").querySelectorAll(".e-detailrow"); Array.from(rows).map((row) => { row.classList.add('newrow'); //add class for display detailrow }); }
<style> .e-detailrow { display: none; //hide detailrow Initially } .newrow { display: table-row; //show detailrow } </style> _Layout.cshtml:- <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>ServerApp</title> <base rel='nofollow' href="~/" /> <link rel="stylesheet" rel='nofollow' href="css/bootstrap/bootstrap.min.css" /> . . . <script src="~/TreeGridfile.js"></script> </head>
|
Hi,
thanks for your provided approach.
Unfortunately, this one does not fully meet our requirements, so we chosed to DataGrid as base and implement the hierarchy handling by ourself.
for anyone who is facing same problem, here is our approach:
GridHierarchy.razor.cs
using System; |
javascript
function GridHierarchy_UpdateRowVisibility( id, visibleRows ) |
Hi Christoph,
Thank you for sharing the solution, it will be useful.
Please get back to us for further assistance.