Skip to content

Commit

Permalink
Up: adding item row templating
Browse files Browse the repository at this point in the history
  • Loading branch information
mouadcherkaoui committed Mar 24, 2020
1 parent 1a2d6f5 commit 0a36567
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/BxBlazor/Components/BxDataTableV2.razor
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,18 @@
<label for="@prefix--checkbox-@(index)" class="@prefix--checkbox-label" aria-label="Label name"></label>
</td>
}
@foreach (var header in headers)
@if(!(ItemTemplate is null))
{
<td>
@typeof(TItem).GetProperty(header).GetValue(item)
</td>
@ItemTemplate.Invoke(item)
}
else
{
@foreach (var header in headers)
{
<td>
@typeof(TItem).GetProperty(header).GetValue(item)
</td>
}
}
<td class="@prefix--table-column-menu">
@if (ItemActionsMenu != null)
Expand Down Expand Up @@ -198,7 +205,14 @@
public EventCallback OnSelectItemCallback { get; set; }

[Parameter]
public RenderFragment ItemDetails { get; set; }
public RenderFragment<TItem> ItemDetails { get; set; }

[Parameter]
public RenderFragment<TItem> ItemTemplate { get; set; }

[Parameter]
public RenderFragment<TItem> HeaderTemplate { get; set; }

public List<string> headers { get; }
= typeof(TItem).GetProperties().Select(p => p.Name).ToList();

Expand Down

0 comments on commit 0a36567

Please sign in to comment.