Skip to content

Commit 444dbc0

Browse files
Merge pull request #1 from Backiaraj/treeview
Update the project
2 parents 8a6d57a + 392865c commit 444dbc0

Some content is hidden

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

73 files changed

+1721
-1443
lines changed
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
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>
1+
<Router AppAssembly="@typeof(App).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4+
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
5+
</Found>
6+
<NotFound>
7+
<PageTitle>Not found</PageTitle>
8+
<LayoutView Layout="@typeof(MainLayout)">
9+
<p role="alert">Sorry, there's nothing at this address.</p>
10+
</LayoutView>
11+
</NotFound>
12+
</Router>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.2" />
11+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.2" PrivateAssets="all" />
12+
<PackageReference Include="Syncfusion.Blazor.Navigations" Version="23.1.40" />
13+
<PackageReference Include="Syncfusion.Blazor.Themes" Version="23.1.40" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\Shared\CustomTreeViewItems.Shared.csproj" />
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
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-
}
1+
@page "/counter"
2+
3+
<PageTitle>Counter</PageTitle>
4+
5+
<h1>Counter</h1>
6+
7+
<p role="status">Current count: @currentCount</p>
8+
9+
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
10+
11+
@code {
12+
private int currentCount = 0;
13+
14+
private void IncrementCount()
15+
{
16+
currentCount++;
17+
}
18+
}
Lines changed: 47 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,47 @@
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-
}
1+
@page "/fetchdata"
2+
@using CustomTreeViewItems.Shared
3+
@inject HttpClient Http
4+
5+
<PageTitle>Weather forecast</PageTitle>
6+
7+
<h1>Weather forecast</h1>
8+
9+
<p>This component demonstrates fetching data from the server.</p>
10+
11+
@if (forecasts == null)
12+
{
13+
<p><em>Loading...</em></p>
14+
}
15+
else
16+
{
17+
<table class="table">
18+
<thead>
19+
<tr>
20+
<th>Date</th>
21+
<th>Temp. (C)</th>
22+
<th>Temp. (F)</th>
23+
<th>Summary</th>
24+
</tr>
25+
</thead>
26+
<tbody>
27+
@foreach (var forecast in forecasts)
28+
{
29+
<tr>
30+
<td>@forecast.Date.ToShortDateString()</td>
31+
<td>@forecast.TemperatureC</td>
32+
<td>@forecast.TemperatureF</td>
33+
<td>@forecast.Summary</td>
34+
</tr>
35+
}
36+
</tbody>
37+
</table>
38+
}
39+
40+
@code {
41+
private WeatherForecast[]? forecasts;
42+
43+
protected override async Task OnInitializedAsync()
44+
{
45+
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("WeatherForecast");
46+
}
47+
}

Client/Pages/Index.razor

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

Client/Program.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using CustomTreeViewItems.Client;
2+
using Microsoft.AspNetCore.Components.Web;
3+
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
4+
using Syncfusion.Blazor;
5+
6+
var builder = WebAssemblyHostBuilder.CreateDefault(args);
7+
builder.RootComponents.Add<App>("#app");
8+
builder.RootComponents.Add<HeadOutlet>("head::after");
9+
10+
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
11+
builder.Services.AddSyncfusionBlazor();
12+
await builder.Build().RunAsync();

0 commit comments

Comments
 (0)