Skip to content

Commit e69fca4

Browse files
authored
Committed the example project.
1 parent 626513a commit e69fca4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1436
-0
lines changed

App.razor

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Router AppAssembly="@typeof(Program).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4+
</Found>
5+
<NotFound>
6+
<LayoutView Layout="@typeof(MainLayout)">
7+
<p>Sorry, there's nothing at this address.</p>
8+
</LayoutView>
9+
</NotFound>
10+
</Router>

MyBlazorApp.csproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.1</TargetFramework>
5+
<RazorLangVersion>3.0</RazorLangVersion>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0" />
10+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0" PrivateAssets="all" />
11+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0" PrivateAssets="all" />
12+
<PackageReference Include="Syncfusion.Blazor" Version="18.2.0.55" />
13+
<PackageReference Include="System.Net.Http.Json" Version="3.2.0" />
14+
</ItemGroup>
15+
16+
</Project>

MyBlazorApp.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30128.74
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyBlazorApp", "MyBlazorApp.csproj", "{503A5250-193B-4B73-9B19-47A8D13CE564}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{503A5250-193B-4B73-9B19-47A8D13CE564}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{503A5250-193B-4B73-9B19-47A8D13CE564}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{503A5250-193B-4B73-9B19-47A8D13CE564}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{503A5250-193B-4B73-9B19-47A8D13CE564}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {BEC89F30-B306-4671-AD7C-0ECA5D3BC91D}
24+
EndGlobalSection
25+
EndGlobal

Pages/Counter.razor

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@page "/counter"
2+
3+
<h1>Counter</h1>
4+
5+
<p>Current count: @currentCount</p>
6+
7+
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
8+
9+
@code {
10+
private int currentCount = 0;
11+
12+
private void IncrementCount()
13+
{
14+
currentCount++;
15+
}
16+
}

Pages/FetchData.razor

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
@page "/fetchdata"
2+
@inject HttpClient Http
3+
4+
<h1>Weather forecast</h1>
5+
6+
<p>This component demonstrates fetching data from the server.</p>
7+
8+
@if (forecasts == null)
9+
{
10+
<p><em>Loading...</em></p>
11+
}
12+
else
13+
{
14+
<table class="table">
15+
<thead>
16+
<tr>
17+
<th>Date</th>
18+
<th>Temp. (C)</th>
19+
<th>Temp. (F)</th>
20+
<th>Summary</th>
21+
</tr>
22+
</thead>
23+
<tbody>
24+
@foreach (var forecast in forecasts)
25+
{
26+
<tr>
27+
<td>@forecast.Date.ToShortDateString()</td>
28+
<td>@forecast.TemperatureC</td>
29+
<td>@forecast.TemperatureF</td>
30+
<td>@forecast.Summary</td>
31+
</tr>
32+
}
33+
</tbody>
34+
</table>
35+
}
36+
37+
@code {
38+
private WeatherForecast[] forecasts;
39+
40+
protected override async Task OnInitializedAsync()
41+
{
42+
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
43+
}
44+
45+
public class WeatherForecast
46+
{
47+
public DateTime Date { get; set; }
48+
49+
public int TemperatureC { get; set; }
50+
51+
public string Summary { get; set; }
52+
53+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
54+
}
55+
}

Pages/Index.razor

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
@page "/"
2+
@using Syncfusion.Blazor.Navigations
3+
@inject Microsoft.AspNetCore.Components.NavigationManager UriHelper
4+
5+
6+
<SfTreeView TValue="EmployeeDetails" CssClass="custom">
7+
<TreeViewFieldsSettings TValue="EmployeeDetails" DataSource="@Employee"
8+
Id="EmployeeId" Text="EmployeeName" ParentID="ParentId" HasChildren="HasChild"
9+
Expanded="Expanded">
10+
</TreeViewFieldsSettings>
11+
<TreeViewTemplates>
12+
<NodeTemplate>
13+
@{
14+
var employee = (context as EmployeeDetails);
15+
<img src="@UriHelper.ToAbsoluteUri($"/css/images/Employees/{@employee.Image}.png")"
16+
alt="@employee.Image" class="eimage"/>
17+
<div class="ename">@employee.EmployeeName</div>
18+
<div class="ejob">@employee.Designation</div>
19+
}
20+
</NodeTemplate>
21+
</TreeViewTemplates>
22+
</SfTreeView>
23+
24+
@code
25+
{
26+
public class EmployeeDetails
27+
{
28+
public string EmployeeName { get; set; }
29+
public int EmployeeId { get; set; }
30+
public int? ParentId { get; set; }
31+
public bool HasChild { get; set; }
32+
public bool Expanded { get; set; }
33+
public bool Selected { get; set; }
34+
public string Image { get; set; }
35+
public string Designation { get; set; }
36+
}
37+
38+
public List<EmployeeDetails> Employee = new List<EmployeeDetails>();
39+
40+
protected override void OnInitialized()
41+
{
42+
base.OnInitialized();
43+
Employee.Add(new EmployeeDetails
44+
{
45+
EmployeeId = 1,
46+
EmployeeName = "Steven Buchanan",
47+
HasChild = true,
48+
Expanded = true,
49+
Image = "10",
50+
Designation = "CEO"
51+
});
52+
Employee.Add(new EmployeeDetails
53+
{
54+
EmployeeId = 2,
55+
ParentId = 1,
56+
EmployeeName = "Laura Callahan",
57+
Image = "2",
58+
Designation = "Product Manager",
59+
HasChild = true
60+
});
61+
Employee.Add(new EmployeeDetails
62+
{
63+
EmployeeId = 3,
64+
ParentId = 2,
65+
EmployeeName = "Andrew Fuller",
66+
Image = "7",
67+
Designation = "Team Lead",
68+
HasChild = true
69+
});
70+
Employee.Add(new EmployeeDetails
71+
{
72+
EmployeeId = 4,
73+
ParentId = 3,
74+
EmployeeName = "Anne Dodsworth",
75+
Image = "1",
76+
Designation = "Developer"
77+
});
78+
Employee.Add(new EmployeeDetails
79+
{
80+
EmployeeId = 5,
81+
ParentId = 1,
82+
EmployeeName = "Nancy Davolio",
83+
HasChild = true,
84+
Image = "4",
85+
Designation = "Product Manager"
86+
});
87+
Employee.Add(new EmployeeDetails
88+
{
89+
EmployeeId = 6,
90+
ParentId = 5,
91+
EmployeeName = "Michael Suyama",
92+
Image = "9",
93+
Designation = "Team Lead",
94+
HasChild = true
95+
});
96+
Employee.Add(new EmployeeDetails
97+
{
98+
EmployeeId = 7,
99+
ParentId = 6,
100+
EmployeeName = "Robert King",
101+
Image = "8",
102+
Designation = "Developer"
103+
});
104+
Employee.Add(new EmployeeDetails
105+
{
106+
EmployeeId = 8,
107+
ParentId = 7,
108+
EmployeeName = "Margaret Peacock",
109+
Image = "6",
110+
Designation = "Developer"
111+
});
112+
Employee.Add(new EmployeeDetails
113+
{
114+
EmployeeId = 9,
115+
ParentId = 1,
116+
EmployeeName = "Janet Leverling",
117+
Image = "3",
118+
Designation = "HR"
119+
});
120+
}
121+
}
122+
123+
<style>
124+
.custom.e-treeview .e-fullrow {
125+
height: 72px;
126+
}
127+
128+
.custom.e-treeview .e-list-text {
129+
line-height: normal;
130+
}
131+
132+
.eimage {
133+
float: left;
134+
padding: 11px 16px 11px 0;
135+
height: 48px;
136+
width: 48px;
137+
box-sizing: content-box;
138+
}
139+
140+
.ename {
141+
font-size: 16px;
142+
padding: 14px 0 0;
143+
}
144+
145+
.ejob {
146+
font-size: 14px;
147+
opacity: .87;
148+
}
149+
.custom .e-level-1 > .e-text-content .e-list-text {
150+
font-weight: bold;
151+
}
152+
.custom .e-level-2 > .e-text-content .e-list-text {
153+
color: darkmagenta;
154+
}
155+
.custom .e-level-3 > .e-text-content .e-list-text {
156+
font-style: italic;
157+
}
158+
.custom .e-list-item .e-icons {
159+
font-family: "Customize-icon";
160+
}
161+
162+
@@font-face {
163+
font-family: 'Customize-icon';
164+
src: url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAAKAIAAAwAgT1MvMj0gSRcAAAEoAAAAVmNtYXDnEOdaAAABjAAAADhnbHlmcYqIngAAAcwAAAD8aGVhZBWT124AAADQAAAANmhoZWEHmANtAAAArAAAACRobXR4C9AAAAAAAYAAAAAMbG9jYQBAAH4AAAHEAAAACG1heHABEAAxAAABCAAAACBuYW1l/qscPAAAAsgAAAJ5cG9zdIPGFvoAAAVEAAAAVgABAAADUv9qAFoEAAAA//8D6QABAAAAAAAAAAAAAAAAAAAAAwABAAAAAQAAIKcGUl8PPPUACwPoAAAAANlGSVAAAAAA2UZJUAAAAAAD6QPpAAAACAACAAAAAAAAAAEAAAADACUAAwAAAAAAAgAAAAoACgAAAP8AAAAAAAAAAQPwAZAABQAAAnoCvAAAAIwCegK8AAAB4AAxAQIAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABA5wDnAQNS/2oAWgPpAJYAA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UALQBpAGMAbwBuAEYAbwBuAHQAIABnAGUAbgBlAHIAYQB0AGUAZAAgAHUAcwBpAG4AZwAgAFMAeQBuAGMAZgB1AHMAaQBvAG4AIABNAGUAdAByAG8AIABTAHQAdQBkAGkAbwB3AHcAdwAuAHMAeQBuAGMAZgB1AHMAaQBvAG4ALgBjAG8AbQAAAAACAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMBAgEDAQQAFy1hcnJvdy1jaXJjbGUtcmlnaHQtXzAxEi1hcnJvdy1jaXJjbGUtZG93bgAAAAA=) format('truetype');
165+
font-weight: normal;
166+
font-style: normal;
167+
}
168+
.custom.e-treeview .e-list-item .e-icon-expandable::before, .custom.e-treeview .e-list-item .e-icon-collapsible:before {
169+
content: '\e700';
170+
font-size: 12px;
171+
}
172+
</style>

Program.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Net.Http;
3+
using System.Collections.Generic;
4+
using System.Threading.Tasks;
5+
using System.Text;
6+
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
7+
using Microsoft.Extensions.Configuration;
8+
using Microsoft.Extensions.DependencyInjection;
9+
using Microsoft.Extensions.Logging;
10+
using Syncfusion.Blazor;
11+
12+
namespace MyBlazorApp
13+
{
14+
public class Program
15+
{
16+
public static async Task Main(string[] args)
17+
{
18+
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("Your License Key");
19+
var builder = WebAssemblyHostBuilder.CreateDefault(args);
20+
builder.RootComponents.Add<App>("app");
21+
22+
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
23+
24+
builder.Services.AddSyncfusionBlazor();
25+
await builder.Build().RunAsync();
26+
}
27+
}
28+
}

Properties/launchSettings.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:50039",
7+
"sslPort": 44302
8+
}
9+
},
10+
"profiles": {
11+
"IIS Express": {
12+
"commandName": "IISExpress",
13+
"launchBrowser": true,
14+
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
15+
"environmentVariables": {
16+
"ASPNETCORE_ENVIRONMENT": "Development"
17+
}
18+
},
19+
"MyBlazorApp": {
20+
"commandName": "Project",
21+
"launchBrowser": true,
22+
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
23+
"applicationUrl": "https://localhost:5001;http://localhost:5000",
24+
"environmentVariables": {
25+
"ASPNETCORE_ENVIRONMENT": "Development"
26+
}
27+
}
28+
}
29+
}

Shared/MainLayout.razor

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@inherits LayoutComponentBase
2+
3+
<div class="sidebar">
4+
<NavMenu />
5+
</div>
6+
7+
<div class="main">
8+
<div class="top-row px-4">
9+
<a href="http://blazor.net" target="_blank" class="ml-md-auto">About</a>
10+
</div>
11+
12+
<div class="content px-4">
13+
@Body
14+
</div>
15+
</div>

0 commit comments

Comments
 (0)