Skip to content

Commit d0afe7f

Browse files
obs
1 parent b3517c9 commit d0afe7f

31 files changed

+1367
-0
lines changed
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.29319.158
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ObservableCollection", "ObservableCollection\ObservableCollection.csproj", "{C138E7B4-2F55-4B66-A313-4E2672EBD9A7}"
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+
{C138E7B4-2F55-4B66-A313-4E2672EBD9A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{C138E7B4-2F55-4B66-A313-4E2672EBD9A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{C138E7B4-2F55-4B66-A313-4E2672EBD9A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{C138E7B4-2F55-4B66-A313-4E2672EBD9A7}.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 = {873AB4BC-6C8D-4C3C-8CC6-25473F249D2D}
24+
EndGlobalSection
25+
EndGlobal
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>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
namespace ObservableCollection.Data
4+
{
5+
public class WeatherForecast
6+
{
7+
public DateTime Date { get; set; }
8+
9+
public int TemperatureC { get; set; }
10+
11+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
12+
13+
public string Summary { get; set; }
14+
}
15+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Linq;
3+
using System.Threading.Tasks;
4+
5+
namespace ObservableCollection.Data
6+
{
7+
public class WeatherForecastService
8+
{
9+
private static readonly string[] Summaries = new[]
10+
{
11+
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
12+
};
13+
14+
public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate)
15+
{
16+
var rng = new Random();
17+
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
18+
{
19+
Date = startDate.AddDays(index),
20+
TemperatureC = rng.Next(-20, 55),
21+
Summary = Summaries[rng.Next(Summaries.Length)]
22+
}).ToArray());
23+
}
24+
}
25+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Syncfusion.EJ2.Blazor" Version="17.3.0.10-beta" />
9+
</ItemGroup>
10+
11+
</Project>
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+
int currentCount = 0;
11+
12+
void IncrementCount()
13+
{
14+
currentCount++;
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@page "/error"
2+
3+
4+
<h1 class="text-danger">Error.</h1>
5+
<h2 class="text-danger">An error occurred while processing your request.</h2>
6+
7+
<h3>Development Mode</h3>
8+
<p>
9+
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
10+
</p>
11+
<p>
12+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
13+
It can result in displaying sensitive information from exceptions to end users.
14+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
15+
and restarting the app.
16+
</p>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
@page "/fetchdata"
2+
3+
@using ObservableCollection.Data
4+
@inject WeatherForecastService ForecastService
5+
6+
<h1>Weather forecast</h1>
7+
8+
<p>This component demonstrates fetching data from a service.</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+
WeatherForecast[] forecasts;
41+
42+
protected override async Task OnInitializedAsync()
43+
{
44+
forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
45+
}
46+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
@page "/"
2+
3+
<EjsButton ID="add" @onclick="AddRecord">Add Data</EjsButton>
4+
<EjsButton ID="del" @onclick="DeleteRecord">Delete Data</EjsButton>
5+
<EjsButton ID="update" @onclick="UpdateRecord">Update Data</EjsButton>
6+
<EjsGrid DataSource="@ObservableData" AllowPaging="true">
7+
<GridColumns>
8+
<GridColumn Field=@nameof(ObservableDatas.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="@TextAlign.Center" HeaderTextAlign="@TextAlign.Center" Width="140"></GridColumn>
9+
<GridColumn Field=@nameof(ObservableDatas.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>
10+
<GridColumn Field=@nameof(ObservableDatas.Freight) HeaderText="Freight" EditType="EditType.NumericEdit" Format="C2" Width="140" TextAlign="@TextAlign.Right" HeaderTextAlign="@TextAlign.Right"></GridColumn>
11+
<GridColumn Field=@nameof(ObservableDatas.OrderDate) HeaderText="Order Date" EditType="EditType.DatePickerEdit" Format="yMd" Type="ColumnType.Date" Width="160"></GridColumn>
12+
</GridColumns>
13+
</EjsGrid>
14+
@code{
15+
public ObservableCollection<ObservableDatas> ObservableData { get; set; }
16+
List<ObservableDatas> Orders = new List<ObservableDatas>();
17+
private int uniqueid { get; set; }
18+
protected override void OnInitialized()
19+
{
20+
Orders = Enumerable.Range(1, 10).Select(x => new ObservableDatas()
21+
{
22+
OrderID = 10000 + x,
23+
CustomerID = (new string[] { "ALFKI", "ANATR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)],
24+
Freight = 2.1 * x,
25+
OrderDate = DateTime.Now.AddDays(-x),
26+
}).ToList();
27+
ObservableData = new ObservableCollection<ObservableDatas>(Orders);
28+
ObservableData.CollectionChanged += HandleChange;
29+
}
30+
private void HandleChange(object sender, NotifyCollectionChangedEventArgs e)
31+
{
32+
Console.WriteLine(e.Action);
33+
}
34+
public void AddRecord()
35+
{
36+
ObservableData.Add(new ObservableDatas() { OrderID = 10010 + ++uniqueid, CustomerID = "VINET", Freight = 30.35, OrderDate = new DateTime(1991, 05, 15) });
37+
}
38+
public void DeleteRecord()
39+
{
40+
ObservableData.Remove(ObservableData.First());
41+
}
42+
public void UpdateRecord()
43+
{
44+
var name = ObservableData.First();
45+
name.CustomerID = "Record Updated";
46+
}
47+
public class ObservableDatas
48+
{
49+
public int OrderID { get; set; }
50+
public string CustomerID { get; set; }
51+
public DateTime OrderDate { get; set; }
52+
public double Freight { get; set; }
53+
}
54+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@page "/"
2+
@namespace ObservableCollection.Pages
3+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4+
5+
<!DOCTYPE html>
6+
<html lang="en">
7+
<head>
8+
<meta charset="utf-8" />
9+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
10+
<title>ObservableCollection</title>
11+
<base href="~/" />
12+
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
13+
<link href="css/site.css" rel="stylesheet" />
14+
<link href="https://cdn.syncfusion.com/ej2/17.3.10/fabric.css" rel="stylesheet" />
15+
<script src="https://cdn.syncfusion.com/ej2/17.3.10/dist/ej2.min.js"></script>
16+
<script src="https://cdn.syncfusion.com/ej2/17.3.10/dist/ejs.interop.min.js"></script>
17+
</head>
18+
<body>
19+
<app>
20+
@(await Html.RenderComponentAsync<App>(RenderMode.ServerPrerendered))
21+
</app>
22+
23+
<script src="_framework/blazor.server.js"></script>
24+
</body>
25+
</html>

0 commit comments

Comments
 (0)