Skip to content

Commit 809e3fe

Browse files
committed
Prepared UG samples for Blazor DataManager, DatePicker and DateRangePicker components
1 parent 1012692 commit 809e3fe

File tree

191 files changed

+5992
-0
lines changed

Some content is hidden

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

191 files changed

+5992
-0
lines changed

DataManager/Client/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>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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.8" />
11+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.8" PrivateAssets="all" />
12+
<PackageReference Include="Syncfusion.Blazor.Data" Version="20.2.0.49" />
13+
<PackageReference Include="Syncfusion.Blazor.Grid" Version="20.2.0.49" />
14+
<PackageReference Include="Syncfusion.Blazor.Themes" Version="20.2.0.49" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<ProjectReference Include="..\Shared\DataManagerUGSample.Shared.csproj" />
19+
</ItemGroup>
20+
21+
</Project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<table>
2+
<tr>
3+
<td><a href="JsonAdaptor">JsonAdaptor</a></td>
4+
<td><a href="UrlAdaptor">UrlAdaptor</a></td>
5+
<td><a href="ODataAdaptor">ODataAdaptor</a></td>
6+
</tr>
7+
<tr>
8+
<td><a href="ODataV4Adaptor">ODataV4Adaptor</a></td>
9+
<td><a href="WebAPIAdaptor">WebAPIAdaptor</a></td>
10+
</tr>
11+
</table>
12+
13+
14+
<style>
15+
a {
16+
padding-right: 75px;
17+
}
18+
</style>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
@page "/JsonAdaptor"
2+
3+
@using Syncfusion.Blazor
4+
@using Syncfusion.Blazor.Data
5+
@using Syncfusion.Blazor.Grids
6+
<AdaptorRoute></AdaptorRoute>
7+
8+
<SfGrid TValue="EmployeeData" ID="Grid">
9+
<SfDataManager Json=@Employees Adaptor="Adaptors.JsonAdaptor"></SfDataManager>
10+
<GridColumns>
11+
<GridColumn Field=@nameof(EmployeeData.EmployeeID) TextAlign="TextAlign.Center" HeaderText="Employee ID" Width="120"></GridColumn>
12+
<GridColumn Field=@nameof(EmployeeData.Name) HeaderText="First Name" Width="130"></GridColumn>
13+
<GridColumn Field=@nameof(EmployeeData.Title) HeaderText="Title" Width="120"></GridColumn>
14+
</GridColumns>
15+
</SfGrid>
16+
17+
@code {
18+
public class EmployeeData
19+
{
20+
public int EmployeeID { get; set; }
21+
public string Name { get; set; }
22+
public string Title { get; set; }
23+
}
24+
25+
public EmployeeData[] Employees = new EmployeeData[]
26+
{
27+
new EmployeeData { EmployeeID = 1, Name = "Nancy Fuller", Title = "Vice President" },
28+
new EmployeeData { EmployeeID = 2, Name = "Steven Buchanan", Title = "Sales Manager" },
29+
new EmployeeData { EmployeeID = 3, Name = "Janet Leverling", Title = "Sales Representative" },
30+
new EmployeeData { EmployeeID = 4, Name = "Andrew Davolio", Title = "Inside Sales Coordinator" },
31+
new EmployeeData { EmployeeID = 5, Name = "Steven Peacock", Title = "Inside Sales Coordinator" },
32+
new EmployeeData { EmployeeID = 6, Name = "Janet Buchanan", Title = "Sales Representative" },
33+
new EmployeeData { EmployeeID = 7, Name = "Andrew Fuller", Title = "Inside Sales Coordinator" },
34+
new EmployeeData { EmployeeID = 8, Name = "Steven Davolio", Title = "Inside Sales Coordinato" },
35+
new EmployeeData { EmployeeID = 9, Name = "Janet Davolio", Title = "Sales Representative" },
36+
new EmployeeData { EmployeeID = 10, Name = "Andrew Buchanan", Title = "Sales Representative" }
37+
};
38+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@page "/ODataAdaptor"
2+
3+
@using Syncfusion.Blazor
4+
@using Syncfusion.Blazor.Data
5+
@using Syncfusion.Blazor.Grids
6+
<AdaptorRoute></AdaptorRoute>
7+
8+
<SfGrid TValue="EmployeeData" ID="Grid" AllowPaging="true">
9+
<SfDataManager Url="https://js.syncfusion.com/demos/ejServices/Wcf/Northwind.svc/Orders" Adaptor="Adaptors.ODataAdaptor"></SfDataManager>
10+
<GridColumns>
11+
<GridColumn Field=@nameof(EmployeeData.OrderID) TextAlign="TextAlign.Center" HeaderText="Order ID" Width="120"></GridColumn>
12+
<GridColumn Field=@nameof(EmployeeData.CustomerID) TextAlign="TextAlign.Center" HeaderText="Customer Name" Width="130"></GridColumn>
13+
<GridColumn Field=@nameof(EmployeeData.EmployeeID) TextAlign="TextAlign.Center" HeaderText="Employee ID" Width="120"></GridColumn>
14+
</GridColumns>
15+
</SfGrid>
16+
17+
@code {
18+
public class EmployeeData
19+
{
20+
public int OrderID { get; set; }
21+
public string CustomerID { get; set; }
22+
public int EmployeeID { get; set; }
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@page "/ODataV4Adaptor"
2+
3+
@using Syncfusion.Blazor
4+
@using Syncfusion.Blazor.Data
5+
@using Syncfusion.Blazor.Grids
6+
<AdaptorRoute></AdaptorRoute>
7+
8+
<SfGrid TValue="EmployeeData" ID="Grid" AllowPaging="true">
9+
<SfDataManager Url="https://services.odata.org/V4/Northwind/Northwind.svc/Orders/" Adaptor="Adaptors.ODataV4Adaptor"></SfDataManager>
10+
<GridColumns>
11+
<GridColumn Field=@nameof(EmployeeData.OrderID) TextAlign="TextAlign.Center" HeaderText="Order ID" Width="120"></GridColumn>
12+
<GridColumn Field=@nameof(EmployeeData.CustomerID) TextAlign="TextAlign.Center" HeaderText="Customer Name" Width="130"></GridColumn>
13+
<GridColumn Field=@nameof(EmployeeData.EmployeeID) TextAlign="TextAlign.Center" HeaderText="Employee ID" Width="120"></GridColumn>
14+
</GridColumns>
15+
</SfGrid>
16+
17+
@code {
18+
public class EmployeeData
19+
{
20+
public int OrderID { get; set; }
21+
public string CustomerID { get; set; }
22+
public int EmployeeID { get; set; }
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@page "/UrlAdaptor"
2+
3+
@using Syncfusion.Blazor
4+
@using Syncfusion.Blazor.Data
5+
@using Syncfusion.Blazor.Grids
6+
<AdaptorRoute></AdaptorRoute>
7+
8+
<SfGrid TValue="EmployeeData" ID="Grid" AllowPaging="true">
9+
<SfDataManager Url="http://controller.com/actions" Adaptor="Adaptors.UrlAdaptor"></SfDataManager>
10+
<GridColumns>
11+
<GridColumn Field=@nameof(EmployeeData.EmployeeID) TextAlign="TextAlign.Center" HeaderText="Employee ID" Width="120"></GridColumn>
12+
<GridColumn Field=@nameof(EmployeeData.Name) HeaderText="First Name" Width="130"></GridColumn>
13+
<GridColumn Field=@nameof(EmployeeData.Title) HeaderText="Title" Width="120"></GridColumn>
14+
</GridColumns>
15+
</SfGrid>
16+
17+
@code {
18+
public class EmployeeData
19+
{
20+
public int EmployeeID { get; set; }
21+
public string Name { get; set; }
22+
public string Title { get; set; }
23+
}
24+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@page "/WebAPIAdaptor"
2+
3+
@using Syncfusion.Blazor
4+
@using Syncfusion.Blazor.Data
5+
@using Syncfusion.Blazor.Grids
6+
<AdaptorRoute></AdaptorRoute>
7+
8+
<SfGrid TValue="Order" AllowPaging="true">
9+
<SfDataManager Url="https://ej2services.syncfusion.com/production/web-services/api/Orders" Adaptor="Adaptors.WebApiAdaptor"></SfDataManager>
10+
<GridColumns>
11+
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn>
12+
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>
13+
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>
14+
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
15+
</GridColumns>
16+
</SfGrid>
17+
18+
@code {
19+
public class Order
20+
{
21+
public int? OrderID { get; set; }
22+
public string CustomerID { get; set; }
23+
public DateTime? OrderDate { get; set; }
24+
public double? Freight { get; set; }
25+
}
26+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
@page "/CustomBinding"
2+
3+
@using Syncfusion.Blazor
4+
@using Syncfusion.Blazor.Data
5+
@using Syncfusion.Blazor.Grids
6+
7+
<SfGrid TValue="Order" ID="Grid" AllowSorting="true" AllowFiltering="true" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel" })">
8+
<SfDataManager AdaptorInstance="@typeof(CustomAdaptor)" Adaptor="Adaptors.CustomAdaptor"></SfDataManager>
9+
<GridPageSettings PageSize="8"></GridPageSettings>
10+
<GridEditSettings AllowEditing="true" AllowDeleting="true" AllowAdding="true" Mode="@EditMode.Normal"></GridEditSettings>
11+
<GridColumns>
12+
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="@TextAlign.Center" Width="140"></GridColumn>
13+
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>
14+
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Width="150"></GridColumn>
15+
</GridColumns>
16+
</SfGrid>
17+
18+
@code {
19+
public static List<Order> Orders { get; set; }
20+
21+
protected override void OnInitialized()
22+
{
23+
Orders = Enumerable.Range(1, 75).Select(x => new Order()
24+
{
25+
OrderID = 1000 + x,
26+
CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)],
27+
Freight = 2.1 * x,
28+
}).ToList();
29+
}
30+
31+
public class Order
32+
{
33+
public int OrderID { get; set; }
34+
public string CustomerID { get; set; }
35+
public double Freight { get; set; }
36+
}
37+
38+
// Implementing custom adaptor by extending the DataAdaptor class
39+
public class CustomAdaptor : DataAdaptor
40+
{
41+
// Performs data Read operation
42+
public override object Read(DataManagerRequest dm, string key = null)
43+
{
44+
IEnumerable<Order> DataSource = Orders;
45+
if (dm.Search != null && dm.Search.Count > 0)
46+
{
47+
// Searching
48+
DataSource = DataOperations.PerformSearching(DataSource, dm.Search);
49+
}
50+
if (dm.Sorted != null && dm.Sorted.Count > 0)
51+
{
52+
// Sorting
53+
DataSource = DataOperations.PerformSorting(DataSource, dm.Sorted);
54+
}
55+
if (dm.Where != null && dm.Where.Count > 0)
56+
{
57+
// Filtering
58+
DataSource = DataOperations.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);
59+
}
60+
int count = DataSource.Cast<Order>().Count();
61+
if (dm.Skip != 0)
62+
{
63+
//Paging
64+
DataSource = DataOperations.PerformSkip(DataSource, dm.Skip);
65+
}
66+
if (dm.Take != 0)
67+
{
68+
DataSource = DataOperations.PerformTake(DataSource, dm.Take);
69+
}
70+
return dm.RequiresCounts ? new DataResult() { Result = DataSource, Count = count } : (object)DataSource;
71+
}
72+
73+
// Performs Insert operation
74+
public override object Insert(DataManager dm, object value, string key)
75+
{
76+
Orders.Insert(0, value as Order);
77+
return value;
78+
}
79+
80+
// Performs Remove operation
81+
public override object Remove(DataManager dm, object value, string keyField, string key)
82+
{
83+
Orders.Remove(Orders.Where(or => or.OrderID == int.Parse(value.ToString())).FirstOrDefault());
84+
return value;
85+
}
86+
87+
// Performs Update operation
88+
public override object Update(DataManager dm, object value, string keyField, string key)
89+
{
90+
var data = Orders.Where(or => or.OrderID == (value as Order).OrderID).FirstOrDefault();
91+
if (data != null)
92+
{
93+
data.OrderID = (value as Order).OrderID;
94+
data.CustomerID = (value as Order).CustomerID;
95+
data.Freight = (value as Order).Freight;
96+
}
97+
return value;
98+
}
99+
100+
// Performs BatchUpdate operation
101+
public override object BatchUpdate(DataManager dm, object Changed, object Added, object Deleted, string KeyField, string Key,int? dropIndex)
102+
{
103+
if (Changed != null)
104+
{
105+
foreach (var rec in (IEnumerable<Order>)Changed)
106+
{
107+
Orders[0].CustomerID = rec.CustomerID;
108+
}
109+
110+
}
111+
if (Added != null)
112+
{
113+
foreach (var rec in (IEnumerable<Order>)Added)
114+
{
115+
Orders.Add(rec);
116+
}
117+
118+
}
119+
if (Deleted != null)
120+
{
121+
foreach (var rec in (IEnumerable<Order>)Deleted)
122+
{
123+
Orders.RemoveAt(0);
124+
}
125+
126+
}
127+
return Orders;
128+
}
129+
}
130+
}

0 commit comments

Comments
 (0)