I tried the same logic in Blazorise code and it working fine. Might be something in ABP that is interfering maybe. I will need to investigate more and get back to you.
In the meantime just use both .razor and .razor.cs. While not the pretiest, it is a working solution.
This is how Blazor works.
You cannot inherit razor code part. You can only inherit from the class type. What I mean my that? Well, you must know what razor file represents in Blazor component. Basically, it is a RenderFragment that is rendering (in pseudo code).
override void Render()
{
// render elements
}
Once compiled it is just a regular Render
method. That is why you can't inherit it. You must write the implementation again.
Regerding you problem with OnInitializedAsync, I think you can do that. Instead of inherting both .razor and .cs, inherit only the class part.
using Microsoft.AspNetCore.Components;
using System;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Components.Web.LeptonTheme.Components.ApplicationLayout;
using Volo.Abp.DependencyInjection;
namespace TVD_Holdings_Ltd.AvalancheOCP.Blazor.Components.ApplicationLayout
{
[ExposeServices(typeof(DefaultLayout))]
[Dependency(ReplaceServices = true)]
public class DefaultLayoutExtension : DefaultLayout
{
[Inject] IConfiguration Configuration { get; set; }
[Inject] IAlertManager _alertManager { get; set; }
private HubConnection hubConnection;
protected override async Task OnInitializedAsync()
{
// Do something
}
}
}
Hi,
I'm not sure if I understand correctly what you want to accomplish. But I think all you have to do is to add additional key/value translations into the .json file. And then use those keys to read read translation, eg @L["TranslationName"]
.
Hi,
You must have a reference to the MainLayout in order to use: eg.
@layout MainLayout
@inherits LayoutComponentBase
But since you said you don't have access to MainLayout than the only other way I can think of is to repeat the same structure and code from Mainlayout and move it into your TestLayout or any other layout that you have.
Hi, thanks for reaching us.
The problem with Blazor WebAssembly being slow on startup is a known problem. Not just with ABP but with any other sligtly bigger app. The basic reason is that Blazor WebAssembly need to download all the CSS, JS and DLL files to the client in order to be able to start up. In the default Blazor template this is maybe not that obviuos because it doesn't have as near as many features that any regular application need to have. Not to mention you will soon or later add some third-party NuGets and with that increase the app size.
The same problem is with our ABP Blazor. Since everything is a module and they all depends on many diferent modules, they all must be loaded at once to be able to start the application. That is main reason for slowness. We are constantly trying to find a ways to improve it but for now this is the only way. The good news is that we have just added support for Blazor server-side and it is much faster to load and to use. It is on par with regular MVC app. In my opinion it is much stable at this time and you should maybe switch to it instead of using BWA.
Also I see you using Row and Column for horizontal form field. While that can work it is best to go with native approach. eg. with FieldLabel and FieldBody
<Field Horizontal="true">
<FieldLabel ColumnSize="ColumnSize.IsFull.OnTablet.Is2.OnDesktop">Full Name</FieldLabel>
<FieldBody ColumnSize="ColumnSize.IsFull.OnTablet.Is10.OnDesktop">
<TextEdit Autofocus="true" Placeholder="First and last name">
<Feedback>
<ValidationError>Enter full name!</ValidationError>
</Feedback>
</TextEdit>
</FieldBody>
</Field>
You can disable a save button by listening for validations status changed
<Validations Mode="ValidationMode.Auto" StatusChanged="@OnValidationsStatusChanged">
<Validation>
<Field>
<Row>
<Column ColumnSize="ColumnSize.Is5">
<FieldLabel>@L["SupplyNetwork:NetworkType"]</FieldLabel>
</Column>
<Column ColumnSize="ColumnSize.Is7">
<Select TValue="int" @bind-SelectedValue="@EditingEntity.NetworkTypeId">
<ChildContent>
<SelectItem TValue="int" Value="0">@L["SupplyNetwork:SelectNetworkType"]</SelectItem>
@foreach ( var network in networkTypeList )
{
<SelectItem TValue="int" Value="@network.Id">
@network.Name
</SelectItem>
}
</ChildContent>
<Feedback>
<ValidationError />
</Feedback>
</Select>
</Column>
</Row>
</Field>
</Validation>
</Validations>
<Button Color="Color.Primary" Disabled="@saveDisabled">Save</Button>
@code{
Task OnValidationsStatusChanged( ValidationsStatusChangedEventArgs eventArgs )
{
saveDisabled = eventArgs.Status == ValidationStatus.Error;
return Task.CompletedTask;
}
bool saveDisabled;
}
Based on stackstrace message it seems the problem is with one of your model members. I see that all your Data grid fields are defined with nameof
except for Location
, eg. <GridColumn Field="Location" FieldType="@(typeof(string))" Title="@L["OutageReportGrid.Location"]" />
. Maybe that is the problem? Also can you show us the OutageReportDto
class?
I'm not that familiar with Telerik systems but I remember that Blazor don't work well with generic types when accesed through JSInterop. That is the only thing that comes to my mind regarding the error message. Maybe Telerik is doing something under the hood that could make trouble.
As far as I know the OrderBy
only works with single list sources, which is usualy used for repository pattern.
You could try with diferent approach maybe:
Hi,
Regarding the version conflict it might be the same issue as described in https://github.com/abpframework/abp/issues/7997. But without more information I can only guess. If that is the same issue then you will need to wait a little more until we release new ABP.
As of the sidebar problem. While you are still free to use it keep in mind it is an obsolete component for Blazorise. If possible you should switch to the more advanced and feature rich Bar component https://blazorise.com/docs/components/bar/. And if you want to look at the source, look at https://github.com/stsrki/Blazorise/blob/master/Demos/Blazorise.Demo/Layouts/MainLayout.razor