Skip to content

Commit 7904f56

Browse files
authored
Merge pull request #1 from vinoth-Kumar-S/master
Adding ASP.NET Core Grid row template sample
2 parents 48ba565 + 1da0b3d commit 7904f56

File tree

88 files changed

+74589
-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.

88 files changed

+74589
-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="23.1.43" />
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: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
@page
2+
@model IndexModel
3+
@{
4+
ViewData["Title"] = "Home page";
5+
var employee = Employee.GetAllRecords();
6+
}
7+
8+
<ejs-grid id="Grid" dataSource="@employee" detailTemplate="#detailtemplate">
9+
<e-grid-columns>
10+
@*<e-grid-column headerText="Employee Image" textAlign="Center" width="250"></e-grid-column>
11+
<e-grid-column headerText="Employee Details" width="300" textAlign="Left"></e-grid-column>*@
12+
<e-grid-column field="EmployeeID" headerText="Employee ID" textAlign="Right" width="120"></e-grid-column>
13+
<e-grid-column field="FirstName" headerText="Name" width="150"></e-grid-column>
14+
<e-grid-column field="Title" headerText="Title" width="150"></e-grid-column>
15+
<e-grid-column field="HireDate" headerText="Hire Date" format="yMd" width="130"></e-grid-column>
16+
@*<e-grid-column field="Phone" headerText="Phone" width="120"></e-grid-column>
17+
<e-grid-column field="Country" headerText="Country" width="150"></e-grid-column>*@
18+
</e-grid-columns>
19+
</ejs-grid>
20+
21+
<script id="detailtemplate" type="text/x-template">
22+
<tr>
23+
<td class="photo">
24+
<img src="@Url.Content("~/Images/data-grid/${EmployeeID}.png")" alt="${EmployeeID}"/>
25+
</td>
26+
<td class="details">
27+
<table class="cardtable" cellpadding="3" cellspacing="2">
28+
<colgroup>
29+
<col/>
30+
<col/>
31+
</colgroup>
32+
<tbody>
33+
<tr>
34+
<td class="cardheader">First Name</td>
35+
<td>${FirstName}</td>
36+
</tr>
37+
<tr>
38+
<td class="cardheader">Last Name</td>
39+
<td>${LastName} </td>
40+
</tr>
41+
<tr>
42+
<td class="cardheader">Title</td>
43+
<td>${Title}</td>
44+
</tr>
45+
<tr>
46+
<td class="cardheader">Birth Date</td>
47+
<td>${BirthDate.toLocaleDateString()}</td>
48+
</tr>
49+
<tr>
50+
<td class="cardheader">Hire Date</td>
51+
<td>${HireDate.toLocaleDateString()}</td>
52+
</tr>
53+
<tr>
54+
<td class="cardheader">Country</td>
55+
<td>${Country}</td>
56+
</tr>
57+
<tr>
58+
<td class="cardheader">Email ID</td>
59+
<td>${Email}</td>
60+
</tr>
61+
</tbody>
62+
</table>
63+
</td>
64+
</tr>
65+
</script>
66+
67+
<style>
68+
.photo, .details {
69+
border-color: #e0e0e0;
70+
border-style: solid;
71+
border-width: 1px 0px 0px 0px;
72+
}
73+
74+
.photo{
75+
text-align: center;
76+
}
77+
78+
.photo img {
79+
width: 100px;
80+
height: 100px;
81+
border-radius: 50px;
82+
box-shadow: inset 0 0 1px #e0e0e0, inset 0 0 14px rgba(0, 0, 0, 0.2);
83+
}
84+
85+
.details {
86+
padding-left: 18px;
87+
}
88+
89+
.details > table {
90+
width: 100%;
91+
}
92+
93+
.cardtable col {
94+
width: 50%;
95+
}
96+
97+
.cardheader {
98+
font-weight: 600;
99+
}
100+
101+
td {
102+
padding: 2px 20px 3px 4px;
103+
}
104+
</style>

Pages/Index.cshtml.cs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
using System.Dynamic;
4+
namespace DataGrid.Pages
5+
{
6+
public class Employee
7+
{
8+
public Employee(int EmployeeID, string FirstName, string LastName, string Title, DateTime BirthDate, DateTime HireDate, int ReportsTo, string Address, string PostalCode, string Phone, string City, string Country, string mail)
9+
{
10+
this.EmployeeID = EmployeeID;
11+
this.FirstName = FirstName;
12+
this.LastName = LastName;
13+
this.Title = Title;
14+
this.BirthDate = BirthDate;
15+
this.HireDate = HireDate;
16+
this.ReportsTo = ReportsTo;
17+
this.Address = Address;
18+
this.PostalCode = PostalCode;
19+
this.Phone = Phone;
20+
this.City = City;
21+
this.Country = Country;
22+
this.Email = mail;
23+
}
24+
public int EmployeeID { get; set; }
25+
public string FirstName { get; set; }
26+
public string LastName { get; set; }
27+
public string Title { get; set; }
28+
public DateTime BirthDate { get; set; }
29+
public DateTime HireDate { get; set; }
30+
public int ReportsTo { get; set; }
31+
public string Address { get; set; }
32+
public string PostalCode { get; set; }
33+
public string Phone { get; set; }
34+
public string City { get; set; }
35+
public string Country { get; set; }
36+
public string Email { get; set; }
37+
public static List<Employee> GetAllRecords()
38+
{
39+
List<Employee> Emp = new List<Employee>();
40+
Emp.Add(new Employee(1, "Nancy", "Davolio", "Sales Representative", new DateTime(1948, 12, 08), new DateTime(1992, 05, 01), 2, "507 - 20th Ave. E.Apt. 2A ", " 98122", "(206) 555-9857 ", "Seattle ", "USA", "nancy_davolio@gmail.com"));
41+
Emp.Add(new Employee(2, "Andrew", "Fuller", "Vice President, Sales", new DateTime(1952, 02, 19), new DateTime(1992, 08, 14), 4, "908 W. Capital Way", "98401 ", "(206) 555-9482 ", "Kirkland ", "USA", "andrew_fuller@gmail.com"));
42+
Emp.Add(new Employee(3, "Janet", "Leverling", "Sales Representative", new DateTime(1963, 08, 30), new DateTime(1992, 04, 01), 3, " 4110 Old Redmond Rd.", "98052 ", "(206) 555-8122", "Redmond ", "USA", "Janet_leverling@gmail.com"));
43+
Emp.Add(new Employee(4, "Margaret", "Peacock", "Sales Representative", new DateTime(1937, 09, 19), new DateTime(1993, 05, 03), 6, "14 Garrett Hill ", "SW1 8JR ", "(71) 555-4848 ", "London ", "UK", "margaret_peacock@gmail.com"));
44+
Emp.Add(new Employee(5, "Steven", "Buchanan", "Sales Manager", new DateTime(1955, 03, 04), new DateTime(1993, 10, 17), 8, "Coventry HouseMiner Rd. ", "EC2 7JR ", " (206) 555-8122", "Tacoma ", " USA", "steven_buchanan@gmail.com"));
45+
Emp.Add(new Employee(6, "Michael", "Suyama", "Sales Representative", new DateTime(1963, 07, 02), new DateTime(1993, 10, 17), 2, " 7 Houndstooth Rd.", " WG2 7LT", "(71) 555-4444 ", "London ", "UK", "michael_suyama@gmail.com"));
46+
Emp.Add(new Employee(7, "Robert", "King", "Sales Representative", new DateTime(1960, 05, 29), new DateTime(1994, 01, 02), 7, "Edgeham HollowWinchester Way ", "RG1 9SP ", "(71) 555-5598 ", "London", "UK", "robert_king@gmail.com"));
47+
Emp.Add(new Employee(8, "Laura", "Callahan", "Inside Sales Coordinator", new DateTime(1958, 01, 09), new DateTime(1994, 03, 05), 9, "722 Moss Bay Blvd. ", "98033 ", " (206) 555-3412", "Seattle ", "USA ", "laura_callahan@gmail.com"));
48+
Emp.Add(new Employee(9, "Anne", "Dodsworth", "Sales Representative", new DateTime(1966, 01, 27), new DateTime(1994, 11, 15), 5, "4726 - 11th Ave. N.E. ", "98105 ", "(71) 555-5598 ", " London", "UK", "anne_dodsworth@gmail.com"));
49+
return Emp;
50+
}
51+
}
52+
53+
public class IndexModel : PageModel
54+
{
55+
public void OnGet()
56+
{
57+
58+
}
59+
}
60+
}

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: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
<header>
15+
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
16+
<div class="container">
17+
<a class="navbar-brand" asp-area="" asp-page="/Index">DataGrid</a>
18+
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
19+
aria-expanded="false" aria-label="Toggle navigation">
20+
<span class="navbar-toggler-icon"></span>
21+
</button>
22+
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
23+
<ul class="navbar-nav flex-grow-1">
24+
<li class="nav-item">
25+
<a class="nav-link text-dark" asp-area="" asp-page="/Index">Home</a>
26+
</li>
27+
<li class="nav-item">
28+
<a class="nav-link text-dark" asp-area="" asp-page="/Privacy">Privacy</a>
29+
</li>
30+
</ul>
31+
</div>
32+
</div>
33+
</nav>
34+
</header>
35+
<div class="container">
36+
<main role="main" class="pb-3">
37+
@RenderBody()
38+
</main>
39+
</div>
40+
41+
<footer class="border-top footer text-muted">
42+
<div class="container">
43+
&copy; 2023 - DataGrid - <a asp-area="" asp-page="/Privacy">Privacy</a>
44+
</div>
45+
</footer>
46+
47+
<script src="~/lib/jquery/dist/jquery.min.js"></script>
48+
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
49+
<script src="~/js/site.js" asp-append-version="true"></script>
50+
51+
@await RenderSectionAsync("Scripts", required: false)
52+
<ejs-scripts></ejs-scripts>
53+
</body>
54+
</html>

0 commit comments

Comments
 (0)