-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDevExtremeGauge.razor
More file actions
37 lines (31 loc) · 1.2 KB
/
DevExtremeGauge.razor
File metadata and controls
37 lines (31 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
@using Microsoft.JSInterop
@using DevExpress.Blazor
@inject IJSRuntime JS
@implements IAsyncDisposable
<div @ref="Gauge"></div>
@code {
ElementReference Gauge { get; set; }
IJSObjectReference ClientModule { get; set; }
IJSObjectReference ClientGauge { get; set; }
[Parameter]
public object DataSource { get; set; }
protected override async Task OnAfterRenderAsync(bool firstRender) {
if(firstRender) {
await JS.LoadDxResources();
ClientModule = await JS.InvokeAsync<IJSObjectReference>("import", "./DevExtremeComponents/DevExtremeGauge.razor.js");
ClientGauge = await ClientModule.InvokeAsync<IJSObjectReference>("initializeGauge", Gauge, DataSource);
}
await base.OnAfterRenderAsync(firstRender);
}
protected override async Task OnParametersSetAsync() {
if(ClientGauge != null) {
await ClientModule.InvokeVoidAsync("changeGaugeDataSource", ClientGauge, DataSource);
}
}
async ValueTask IAsyncDisposable.DisposeAsync() {
if(ClientGauge != null)
await ClientGauge.DisposeAsync();
if(ClientModule != null)
await ClientModule.DisposeAsync();
}
}