Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor - Base Render in an inherited component doesn't use overridden methods

$
0
0

I'm trying to make a Blazor component that I will then specialize and override some methods.

Base Component ZoomList:

@inherits ComponentBase<div><table class="table"><thead><tr>                @foreach (var str in Headers())                {<th>@str</th>                }</tr></thead><tbody>            @foreach (var item in items)            {<tr>                    @foreach (var str in Rows(item))                    {<td>@str</td>                    }</tr>            }</tbody></table></div>@code {    [Parameter]    public List<Object> items { get; set; }    protected virtual List<string> Rows(Object item) { return new List<string>() { "Placeholder" }; }    protected virtual List<string> Headers() { return new List<string>() { "Placeholder" }; }}

Derivated component ZoomCampaign:

@inherits ZoomList@using MyNamespace.Model@{    this.BuildRenderTree(__builder);}@code {    protected override List<string> Rows(Object item)    {        Campaign camp = item as Campaign;        return new List<string>() {            camp.Id.ToString(),            camp.Nom        };    }    protected override List<string> Headers()    {        return new List<string>() { "#", "Name" };    }}

ZoomCampaign is then called from another page.But this.BuildRenderTree(__builder) doesn't use the overridden methods but is using the base methods.=> My html array is contains the "Placeholder" text, not the text defined in override methods Rows and Headers from ZoomCampaign.

What am I missing? How can I change it so that override methods are the ones that are used during rendering ?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>