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

Rendering blazor component to a string, render mode not supported

$
0
0

I'm trying to get html from RadarChart(chartjs.blazor) component

var html = await blazorRenderer.RenderComponent<RadarChart>();

but I keep getting exception:

Cannot supply a component of type 'x.Components.Dashboard.RadarChart' because the current platform does not support the render mode 'Microsoft.AspNetCore.Components.Web.InteractiveServerRenderMode'.

I need html string so I could use for DinkToPdf export.

Here is brief look at key parts of my RadarChart component.

@rendermode InteractiveServer@using ApexCharts@using x.DTOs@using x.Services@using ChartJs.Blazor@using ChartJs.Blazor.Common@using ChartJs.Blazor.Common.Axes@using ChartJs.Blazor.Common.Enums@using ChartJs.Blazor.Common.Time@using ChartJs.Blazor.Util@using ChartJs.Blazor.LineChart@using Microsoft.EntityFrameworkCore@inject IUserService userService@inject IAnswerService answerService@inject ILogService logService@inject IJSRuntime JSRuntime<canvas id="radarChart"></canvas>@code { private async Task RenderChart() {...     await JSRuntime.InvokeVoidAsync("renderRadarChart", "radarChart", data, options); }

BlazorRenderers function looks like this:

private Task<string> RenderComponent<T>(ParameterView parameters) where T : IComponent       {           return _htmlRenderer.Dispatcher.InvokeAsync(async () =>           {               var output = await _htmlRenderer.RenderComponentAsync<T>(parameters);               return output.ToHtmlString();           });       }

Viewing all articles
Browse latest Browse all 4839

Trending Articles



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