I'm using a hierarchy to open levels of my product, but it ends up creating an empty column. I built a component that recursively generates data grids, and when I call it inside a template within my main data grid, it adds an extra column. How can I prevent this additional column from being created?
Products.razor:
<RadzenDataGrid @ref="productsGrid"
Data="@products"
TItem="ProductDTO"
AllowPaging="true"
PageSize="7"
AllowSorting="true"
AllowFiltering="true"
ColumnWidth="100px"
Style="border-radius: 30px;"
EmptyText="Nenhum produto cadastrado."
GridLines="DataGridGridLines.Both"
ExpandMode="DataGridExpandMode.Multiple"
LoadChildData="@OnRowExpanding">
<HeaderTemplate>
<RadzenButton ButtonStyle="ButtonStyle.Success"
Icon="add_circle"
Text="Adicionar Produto"
Click="@(args => RedirectCreateProduct())"
Style="border-radius: 20px;" />
</HeaderTemplate>
<Template Context="product">
@if (treeCache.TryGetValue(product.Id, out var nodes))
{
<Node Nodes="@nodes" OnToggleExpand="@ToggleRowsExpand" />
}
else
{
<RadzenIcon Icon="autorenew" class="rz-animate-spin" />
<span>Carregando estrutura...</span>
}
</Template>
<Columns>
<RadzenDataGridColumn TItem="ProductDTO"
Property="Name"
Title="Produto"
Width="100px"
CssClass="rz-column-title-content"/>
<RadzenDataGridColumn TItem="ProductDTO"
Property="Code"
Title="Código"
Width="100px" />
<RadzenDataGridColumn TItem="ProductDTO"
Context="product"
Filterable="false"
Sortable="false"
TextAlign="TextAlign.Center"
Frozen="true"
FrozenPosition="FrozenColumnPosition.Right"
Width="50px">
<Template Context="product">
<RadzenUpload Auto="true"
Icon="upload"
ChooseText=""
Url="@GetUploadUrl(product.Id)"
Progress="@(args => OnProgress(args))"
Complete="@(args => OnUploadComplete(args, product))"
Error="@(args => OnUploadError(args))"
Accept=".csv" />
<RadzenButton Icon="edit"
ButtonStyle="ButtonStyle.Info"
Variant="Variant.Flat"
Size="ButtonSize.Medium"
Class="rz-my-1 rz-ms-1"
Click="@(args => RedirectUpdateProduct(product))"
@onclick:stopPropagation="true"
Style="border-radius: 20px;" />
<RadzenButton Icon="delete"
ButtonStyle="ButtonStyle.Danger"
Variant="Variant.Flat"
Size="ButtonSize.Medium"
Shade="Shade.Lighter"
Class="rz-my-1 rz-ms-1"
Click="@(args => ShowDeleteDialog(product))"
@onclick:stopPropagation="true"
Style="border-radius: 20px;" />
</Template>
</RadzenDataGridColumn>
</Columns>
</RadzenDataGrid>
Node.raozr:
<RadzenDataGrid AllowFiltering="true" AllowPaging="true" AllowSorting="true" Data="@Nodes" TItem="TreeNodeDTO"
RowRender="@RowRender" >
<Template Context="node">
<RadzenCard Variant="Variant.Text" Class="rz-background-color-primary-lighter rz-color-on-primary-lighter rz-m-4">
<b>@node.Descricao</b>
</RadzenCard>
@* CASO BASE => Verifica se o nó tem filhos *@
@if (node.Children.Any())
{
@* Recursividade passando o filho *@
<Node Nodes="@node.Children" OnToggleExpand="@OnToggleExpand" />
}
</Template>
<Columns>
<RadzenDataGridColumn Property="@nameof(TreeNodeDTO.Nivel)" Title="Nível" Width="100px" />
<RadzenDataGridColumn Property="@nameof(TreeNodeDTO.NomeArquivo)" Title="Nome" Width="100px" />
<RadzenDataGridColumn Property="@nameof(TreeNodeDTO.TipoServico)" Title="Tipo de Serviço" Width="100px" />
<RadzenDataGridColumn Property="@nameof(TreeNodeDTO.Manufatura)" Title="Manufatura" Width="100px" />
<RadzenDataGridColumn Property="@nameof(TreeNodeDTO.CodPeca)" Title="Código" Width="100px" />
<RadzenDataGridColumn Property="@nameof(TreeNodeDTO.Descricao)" Title="Descrição" Width="150px" />
<RadzenDataGridColumn Property="@nameof(TreeNodeDTO.Qtd)" Title="Quantidade" Width="100px" >
<FooterTemplate>
Quantidade total: <b>@Nodes.Sum(o => o.Qtd)</b>
</FooterTemplate>
</RadzenDataGridColumn>
<RadzenDataGridColumn Property="@nameof(TreeNodeDTO.Revisao)" Title="Revisão" Width="100px" />
</Columns>
</RadzenDataGrid>