Blazor.FamilyTreeJS
2.0.1
See the version list below for details.
dotnet add package Blazor.FamilyTreeJS --version 2.0.1
NuGet\Install-Package Blazor.FamilyTreeJS -Version 2.0.1
<PackageReference Include="Blazor.FamilyTreeJS" Version="2.0.1" />
paket add Blazor.FamilyTreeJS --version 2.0.1
#r "nuget: Blazor.FamilyTreeJS, 2.0.1"
// Install Blazor.FamilyTreeJS as a Cake Addin #addin nuget:?package=Blazor.FamilyTreeJS&version=2.0.1 // Install Blazor.FamilyTreeJS as a Cake Tool #tool nuget:?package=Blazor.FamilyTreeJS&version=2.0.1
Blazor.FamilyTreeJS
This is a wrapper library for FamilyTreeJS and it is only compatible for Blazor WASM.
FamilyTreeJS version: 1.9.18
See samples on Github page.
Installation
Install from Nuget.
dotnet add package Blazor.FamilyTreeJS --version <latest-version>
Depenencies
Register Blazor.FamilyTreeJS
dependencies.
builder.Services.AddBlazorFamilyJS();
IJSRuntime configuration
Configure IJSRuntime
's JsonSerializerOptions
. This allows System.Text.Json
to ignore null
when
serializing to JSON and send that JSON to Javascript. Note this affects globally.
var app = builder
.Build()
.ConfigureIJSRuntimeJsonOptions();
Enable C# callback interop with Javascript
This library depends on the library Blazor.Core
in which provides the feature to help
serialize/deserialize C# callback to Javascript. To ensure Blazor.FamilyTreeJS
work
correctly, you must call RegisterAttachReviverAsync()
from the Blazor.Core
library.
var webHost = builder
.Build()
.ConfigureIJSRuntimeJsonOptions();
await webHost.Services.RegisterAttachReviverAsync();
await webHost.RunAsync();
Serialize/deserialize derived types
If you have classes/records that inhereit from classes/records in this library, then you may
need to use the following extension method, UseDerivedTypes<BaseType>([derive types])
.
This allows serializing your derived classes/records with all of their properties.
var app = builder
.Build()
.ConfigureIJSRuntimeJsonOptions();
.UseDerivedTypes<Node>(typeof(NodeWithProfession))
.UseDerivedTypes<NodeMenu>(typeof(CollapseNodeMenu), typeof(DrawLineNodeMenu));
public record NodeWithProfession : Node
{
public string? Job { get; init; } = null;
}
public record CollapseNodeMenu : NodeMenu
{
public Menu? Collapse { get; init; } = null;
}
public record DrawLineNodeMenu : NodeMenu
{
public Menu? Draw { get; init; } = null;
}
Usage
Simplest usage is to provide a tree id.
<FamilyTree TreeId="my-tree" />
This library is heavily driven by the FamilyTreeOptions
class so almost
every control and UI are specified via this class. This C# class mirrors this
Typescript options interface.
<FamilyTree TreeId="my-tree" Options=@new() { Mode = "dark" } />
Please refer to the sample project for more examples.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- Blazor.Core (>= 1.0.9)
- Microsoft.AspNetCore.Components.Web (>= 7.0.11)
- Microsoft.AspNetCore.Components.WebAssembly (>= 7.0.10)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.