Skip to content

Commit

Permalink
[HxGrid] Placeholders do not use ItemCssClass - pass only index
Browse files Browse the repository at this point in the history
  • Loading branch information
Harvey1214 committed Jul 1, 2024
1 parent c54a0d0 commit dbdce31
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions Havit.Blazor.Components.Web.Bootstrap/Grids/HxGrid.razor
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,24 @@
</tr>
</thead>
<tbody>
@{
RenderFragment<int> placeholderRowTemplate = (int rowIndex) =>
@<tr @key="@rowIndex"
height="@((ContentNavigationModeEffective == GridContentNavigationMode.InfiniteScroll) ? rowHeight : null)"
class="@ItemRowCssClassEffective"
@onclick:stopPropagation>

@foreach (IHxGridColumn<TItem> column in columnsToRender)
{
// same as above this else section
GridCellTemplate cellTemplate = column.GetItemPlaceholderCellTemplate(new GridPlaceholderCellContext { Index = rowIndex });
<td @key="@column" class="@cellTemplate.CssClass">
@cellTemplate.Template
</td>
}
</tr>;
}

@if (shouldRenderData)
{

Expand Down Expand Up @@ -152,30 +170,14 @@
}
</text>;

RenderFragment<PlaceholderContext> placeholderRowTemplate = (PlaceholderContext context) =>
@<tr @key="@context.Index"
height="@((ContentNavigationModeEffective == GridContentNavigationMode.InfiniteScroll) ? rowHeight : null)"
class="@ItemRowCssClassEffective"
@onclick:stopPropagation>

@foreach (IHxGridColumn<TItem> column in columnsToRender)
{
// same as above this else section
GridCellTemplate cellTemplate = column.GetItemPlaceholderCellTemplate(new GridPlaceholderCellContext { Index = context.Index });
<td @key="@column" class="@cellTemplate.CssClass">
@cellTemplate.Template
</td>
}
</tr>;

@if (ContentNavigationModeEffective == GridContentNavigationMode.InfiniteScroll)
{
<Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize TItem="TItem" @ref="_infiniteScrollVirtualizeComponent" ItemsProvider="VirtualizeItemsProvider" ItemSize="@ItemRowHeightEffective" OverscanCount="@OverscanCountEffective" SpacerElement="tr">
<ItemContent>
@rowTemplate(context)
</ItemContent>
<Placeholder Context="placeholderContext">
@placeholderRowTemplate(placeholderContext)
@placeholderRowTemplate(placeholderContext.Index)
</Placeholder>
</Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize>
}
Expand All @@ -198,7 +200,7 @@
for (int i = 0; i < rowsToRender; i++)
{
GridPlaceholderCellContext placeholderContext = new GridPlaceholderCellContext { Index = pageOffset + i };
@placeholderRowTemplate(placeholderContext)
@placeholderRowTemplate(placeholderContext.Index)
}
}
else
Expand Down

0 comments on commit dbdce31

Please sign in to comment.