Skip to content

Commit 1dbbd3e

Browse files
Merge pull request #1 from MeenaAlagiah/master
Adding Toolbar sample in Blazor Pivot Table
2 parents fd3ae4d + 3b194c6 commit 1dbbd3e

30 files changed

+1640
-2
lines changed

App.razor

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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>

BlazorAppPivotTable.csproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.9" />
11+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.9" PrivateAssets="all" />
12+
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.1.1" />
13+
<PackageReference Include="Syncfusion.Blazor.PivotTable" Version="21.1.41" />
14+
<PackageReference Include="Syncfusion.Blazor.Themes" Version="21.1.41" />
15+
</ItemGroup>
16+
17+
</Project>

Pages/Counter.razor

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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+
}
19+
@*@code {
20+
SfPivotView<ProductDetails> Pivot;
21+
public List<ToolbarItems> PivotToolbar = new List<ToolbarItems> {
22+
ToolbarItems.New,
23+
ToolbarItems.Save,
24+
ToolbarItems.SaveAs,
25+
ToolbarItems.Rename,
26+
ToolbarItems.Remove,
27+
28+
ToolbarItems.Grid,
29+
ToolbarItems.Chart,
30+
ToolbarItems.Export,
31+
ToolbarItems.SubTotal,
32+
ToolbarItems.GrandTotal,
33+
ToolbarItems.Formatting,
34+
ToolbarItems.FieldList
35+
};
36+
public List<ChartSeriesType> chartTypes = new List<ChartSeriesType> {
37+
ChartSeriesType.Column,
38+
ChartSeriesType.Bar,
39+
ChartSeriesType.Line,
40+
ChartSeriesType.Area,
41+
};
42+
43+
public string InitReport { get; set; }
44+
public string[] Name { get; set; }
45+
public List<string> Report = new List<string>();
46+
public List<string> ReportName = new List<string>();
47+
public void SaveReport(SaveReportArgs args)
48+
{
49+
int i = 0;
50+
bool IsSaved = false;
51+
for (i = 0; i < this.ReportName.Count; i++)
52+
{}
53+
if (this.ReportName[i] == args.ReportName)
54+
{
55+
this.Report[i] = args.Report;
56+
IsSaved = true;
57+
}
58+
}
59+
if (args.Report != null && !(IsSaved))
60+
{
61+
this.Report.Add(args.Report);
62+
this.ReportName.Add(args.ReportName);
63+
}
64+
}
65+
public void FetchReport(FetchReportArgs args)
66+
{
67+
args.ReportName = ReportName.ToArray();
68+
}
69+
public async Task LoadReport(LoadReportArgs args)
70+
{
71+
int i = 0;
72+
int j = 0;
73+
for (i = 0; i < ReportName.Count; i++)
74+
{
75+
if (ReportName[i] == args.ReportName)
76+
{
77+
j = i;
78+
}
79+
}
80+
await this.Pivot.LoadPersistDataAsync(Report[j]);
81+
}
82+
public async Task RemoveReport(RemoveReportArgs args)
83+
{
84+
int i = 0;
85+
for (i = 0; i < ReportName.Count; i++)
86+
{
87+
if (ReportName[i] == args.ReportName)
88+
{
89+
ReportName.RemoveAt(i);
90+
Report.RemoveAt(i);
91+
break;
92+
}
93+
}
94+
if (Report.Count > 0)
95+
{
96+
await this.Pivot.LoadPersistDataAsync(Report[0]);
97+
}
98+
}
99+
public void RenameReport(RenameReportArgs args)
100+
{
101+
if (args.IsReportExists)
102+
{
103+
int j = 0;
104+
for (j = 0; j < ReportName.Count; j++)
105+
{
106+
if (ReportName[j] == args.Rename)
107+
{
108+
ReportName.RemoveAt(j);
109+
Report.RemoveAt(j);
110+
break;
111+
}
112+
}
113+
}
114+
int i = 0;
115+
for (i = 0; i <= (ReportName.Count - 1); i++)
116+
{
117+
if (ReportName[i] == args.ReportName)
118+
{
119+
ReportName[i] = args.Rename;
120+
}
121+
}
122+
}
123+
*@

Pages/FetchData.razor

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

0 commit comments

Comments
 (0)