Skip to content

Commit f8c0545

Browse files
Adding Core DataGrid Data Annotation sample
Adding Core DataGrid Data Annotation sample
1 parent b4e6c72 commit f8c0545

File tree

79 files changed

+74473
-1
lines changed

Some content is hidden

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

79 files changed

+74473
-1
lines changed

DataGrid.csproj

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
10+
<NoWarn>1701;1702;</NoWarn>
11+
</PropertyGroup>
12+
13+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
14+
<NoWarn>1701;1702;</NoWarn>
15+
</PropertyGroup>
16+
17+
<ItemGroup>
18+
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="24.1.45" />
19+
</ItemGroup>
20+
21+
</Project>

DataGrid.csproj.user

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<ActiveDebugProfile>https</ActiveDebugProfile>
5+
</PropertyGroup>
6+
</Project>

DataGrid.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 17
4+
VisualStudioVersion = 17.6.33717.318
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataGrid", "DataGrid.csproj", "{04F3CBC2-96ED-4D59-9BCE-E36B83397DE3}"
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+
{04F3CBC2-96ED-4D59-9BCE-E36B83397DE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{04F3CBC2-96ED-4D59-9BCE-E36B83397DE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{04F3CBC2-96ED-4D59-9BCE-E36B83397DE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{04F3CBC2-96ED-4D59-9BCE-E36B83397DE3}.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 = {F4DA1DB5-98EB-44CA-A1B6-1C6A1C9C7083}
24+
EndGlobalSection
25+
EndGlobal

Pages/Error.cshtml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@page
2+
@model ErrorModel
3+
@{
4+
ViewData["Title"] = "Error";
5+
}
6+
7+
<h1 class="text-danger">Error.</h1>
8+
<h2 class="text-danger">An error occurred while processing your request.</h2>
9+
10+
@if (Model.ShowRequestId)
11+
{
12+
<p>
13+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
14+
</p>
15+
}
16+
17+
<h3>Development Mode</h3>
18+
<p>
19+
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
20+
</p>
21+
<p>
22+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
23+
It can result in displaying sensitive information from exceptions to end users.
24+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
25+
and restarting the app.
26+
</p>

Pages/Error.cshtml.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
using System.Diagnostics;
4+
5+
namespace DataGrid.Pages
6+
{
7+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
8+
[IgnoreAntiforgeryToken]
9+
public class ErrorModel : PageModel
10+
{
11+
public string? RequestId { get; set; }
12+
13+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
14+
15+
private readonly ILogger<ErrorModel> _logger;
16+
17+
public ErrorModel(ILogger<ErrorModel> logger)
18+
{
19+
_logger = logger;
20+
}
21+
22+
public void OnGet()
23+
{
24+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
25+
}
26+
}
27+
}

Pages/Index.cshtml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@page
2+
@model IndexModel
3+
@{
4+
ViewData["Title"] = "Home page";
5+
var order = OrderDetails.GetAllRecords();
6+
var type = typeof(OrderDetails);
7+
}
8+
9+
<ejs-grid id="Grid" tvalue="@type" dataSource="@order" allowPaging="true">
10+
<e-grid-pagesettings pageSize="10"></e-grid-pagesettings>
11+
<e-grid-editsettings allowEditing="true"></e-grid-editsettings>
12+
@* <e-grid-columns>
13+
<e-grid-column field="OrderID" headerText="Order ID" textAlign="Right" width="120"></e-grid-column>
14+
<e-grid-column field="CustomerID" headerText="Customer Name" width="150"></e-grid-column>
15+
<e-grid-column field="OrderDate" headerText=" Order Date" format="yMd" width="130"
16+
textAlign="Right"></e-grid-column>
17+
<e-grid-column field="Freight" headerText="Freight" format="C2" width="120"
18+
textAlign="Right"></e-grid-column>
19+
<e-grid-column field="ShipCity" headerText="Ship City" width="150"></e-grid-column>
20+
</e-grid-columns>*@
21+
</ejs-grid>
22+

Pages/Index.cshtml.cs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
using Newtonsoft.Json.Linq;
4+
using System.Dynamic;
5+
using System.Xml.Linq;
6+
using System.ComponentModel.DataAnnotations;
7+
namespace DataGrid.Pages
8+
{
9+
public class OrderDetails
10+
{
11+
public static List<OrderDetails> order = new List<OrderDetails>();
12+
13+
public OrderDetails(int OrderID, string CustomerId, double Freight,
14+
DateTime OrderDate, string ShipCity)
15+
{
16+
this.OrderID = OrderID;
17+
this.CustomerID = CustomerId;
18+
this.Freight = Freight;
19+
this.ShipCity = ShipCity;
20+
this.OrderDate = OrderDate;
21+
}
22+
23+
public static List<OrderDetails> GetAllRecords()
24+
{
25+
if (order.Count() == 0)
26+
{
27+
int code = 1001;
28+
for (int i = 1; i < 3; i++)
29+
{
30+
order.Add(new OrderDetails(code + 1, "ALFKI", 2.3 * i, new DateTime(1991, 05, 15), "Berlin"));
31+
order.Add(new OrderDetails(code + 2, "ANATR", 3.3 * i, new DateTime(1990, 04, 04), "Madrid"));
32+
order.Add(new OrderDetails(code + 3, "JOE", 4.3 * i, new DateTime(1957, 11, 30), "Cholchester"));
33+
order.Add(new OrderDetails(code + 4, "BLONP", 5.3 * i, new DateTime(1930, 10, 22), "Marseille"));
34+
order.Add(new OrderDetails(code + 5, "BOLID", 6.3 * i, new DateTime(1953, 02, 18), "Tsawassen"));
35+
order.Add(new OrderDetails(code + 6, "MICHAEL", 6.3 * i, new DateTime(1953, 02, 18), "Berlin"));
36+
code += 5;
37+
}
38+
}
39+
return order;
40+
}
41+
[Key]
42+
public long OrderID { get; set; }
43+
[Display(Name = "Customer Name")]
44+
public string CustomerID { get; set; }
45+
[Editable(false)]
46+
[DisplayFormat(DataFormatString ="C2")]
47+
public double Freight { get; set; }
48+
49+
public string ShipCity { get; set; }
50+
[DisplayFormat(DataFormatString ="yMd")]
51+
public DateTime OrderDate { get; set; }
52+
}
53+
54+
public class IndexModel : PageModel
55+
{
56+
57+
}
58+
}

Pages/Privacy.cshtml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@page
2+
@model PrivacyModel
3+
@{
4+
ViewData["Title"] = "Privacy Policy";
5+
}
6+
<h1>@ViewData["Title"]</h1>
7+
8+
<p>Use this page to detail your site's privacy policy.</p>

Pages/Privacy.cshtml.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
4+
namespace DataGrid.Pages
5+
{
6+
public class PrivacyModel : PageModel
7+
{
8+
private readonly ILogger<PrivacyModel> _logger;
9+
10+
public PrivacyModel(ILogger<PrivacyModel> logger)
11+
{
12+
_logger = logger;
13+
}
14+
15+
public void OnGet()
16+
{
17+
}
18+
}
19+
}

Pages/Shared/_Layout.cshtml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>@ViewData["Title"] - DataGrid</title>
7+
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
8+
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
9+
<link rel="stylesheet" href="~/DataGrid.styles.css" asp-append-version="true" />
10+
<link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/23.1.36/fluent.css" />
11+
<script src="https://cdn.syncfusion.com/ej2/23.1.36/dist/ej2.min.js"></script>
12+
</head>
13+
<body>
14+
<div style="padding:2% 10%">
15+
<main role="main" class="pb-3">
16+
@RenderBody()
17+
</main>
18+
</div>
19+
<script src="~/lib/jquery/dist/jquery.min.js"></script>
20+
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
21+
<script src="~/js/site.js" asp-append-version="true"></script>
22+
23+
@await RenderSectionAsync("Scripts", required: false)
24+
<ejs-scripts></ejs-scripts>
25+
</body>
26+
</html>

0 commit comments

Comments
 (0)