Skip to content

Commit b756bcb

Browse files
authored
Merge pull request #1 from vinoth-Kumar-S/master
ASP.NET Core DataGrid column template
2 parents cb11aec + a9b830e commit b756bcb

File tree

88 files changed

+74563
-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

+74563
-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: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
@page
2+
@model IndexModel
3+
@using Syncfusion.EJ2
4+
@{
5+
ViewData["Title"] = "Home page";
6+
var employee = Employee.GetAllRecords();
7+
}
8+
9+
<ejs-grid id="Grid" dataSource="@employee" width="85%">
10+
<e-grid-columns>
11+
<e-grid-column headerText="Employee Image" textAlign=Center template="#datatemplate" width="120"></e-grid-column>
12+
<e-grid-column field="EmployeeID" textAlign="Right" headerTemplate="#employeetemplate" 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" headerTemplate="#datetemplate" 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="70"></e-grid-column>
18+
<e-grid-column headerText="Active" template="#conditionaltemplate" textAlign=Center width="120"></e-grid-column>
19+
</e-grid-columns>
20+
</ejs-grid>
21+
22+
<style>
23+
@@font-face {
24+
font-family: 'ej2-headertemplate';
25+
src: url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAAKAIAAAwAgT1MvMj1vTFIAAAEoAAAAVmNtYXDS2c5qAAABjAAAAEBnbHlmQmNFrQAAAdQAAANoaGVhZBRdbkIAAADQAAAANmhoZWEIUQQEAAAArAAAACRobXR4DAAAAAAAAYAAAAAMbG9jYQCOAbQAAAHMAAAACG1heHABHgENAAABCAAAACBuYW1lohGZJQAABTwAAAKpcG9zdA2o3w0AAAfoAAAAQAABAAAEAAAAAFwEAAAAAAAD9AABAAAAAAAAAAAAAAAAAAAAAwABAAAAAQAATBXy9l8PPPUACwQAAAAAANillKkAAAAA2KWUqQAAAAAD9APzAAAACAACAAAAAAAAAAEAAAADAQEAEQAAAAAAAgAAAAoACgAAAP8AAAAAAAAAAQQAAZAABQAAAokCzAAAAI8CiQLMAAAB6wAyAQgAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABA5wLpYAQAAAAAXAQAAAAAAAABAAAAAAAABAAAAAQAAAAEAAAAAAAAAgAAAAMAAAAUAAMAAQAAABQABAAsAAAABgAEAAEAAucC6WD//wAA5wLpYP//AAAAAAABAAYABgAAAAIAAQAAAAAAjgG0ABEAAAAAA8kD8wADAAcACwAPABMAFwAbAB8AIwAnACsALwAzADcAOwBPAGsAACUVIzUjFSM1IxUjNSMVIzUjFSM1JRUjNSMVIzUjFSM1IxUjNSMVIzUlFSM1IxUjNSMVIzUjFSM1IxUjNQMVHwYhPwcRITcjDwghNS8HIzUjFSE1IwN2U1NTU1RTU1NTAuxTU1NTVFNTU1MC7FNTU1NUU1NTU1QCAwUGBggIA0QICAcHBQQBAvxsp30ICAcHAgUDAQEDlAECBAUHBwgIfVP+YFOzU1NTU1NTU1NTU6dUVFRUVFRUVFRUplNTU1NTU1NTU1P+NgQIBwcGBAMCAQIEBQcHAwgCdPoBAgQFAwcHCIF8CQgHBgUEAgFTU1MABAAAAA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bXBsYXRlUmVndWxhcmVqMi1oZWFkZXJ0ZW1wbGF0ZWVqMi1oZWFkZXJ0ZW1wbGF0ZVZlcnNpb24gMS4wZWoyLWhlYWRlcnRlbXBsYXRlRm9udCBnZW5lcmF0ZWQgdXNpbmcgU3luY2Z1c2lvbiBNZXRybyBTdHVkaW93d3cuc3luY2Z1c2lvbi5jb20AIABlAGoAMgAtAGgAZQBhAGQAZQByAHQAZQBtAHAAbABhAHQAZQBSAGUAZwB1AGwAYQByAGUAagAyAC0AaABlAGEAZABlAHIAdABlAG0AcABsAGEAdABlAGUAagAyAC0AaABlAGEAZABlAHIAdABlAG0AcABsAGEAdABlAFYAZQByAHMAaQBvAG4AIAAxAC4AMABlAGoAMgAtAGgAZQBhAGQAZQByAHQAZQBtAHAAbABhAHQAZQBGAG8AbgB0ACAAZwBlAG4AZQByAGEAdABlAGQAIAB1AHMAaQBuAGcAIABTAHkAbgBjAGYAdQBzAGkAbwBuACAATQBlAHQAcgBvACAAUwB0AHUAZABpAG8AdwB3AHcALgBzAHkAbgBjAGYAdQBzAGkAbwBuAC4AYwBvAG0AAAAAAgAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAQIBAwEEAAtCVF9DYWxlbmRhcghlbXBsb3llZQAA) format('truetype');
26+
font-weight: normal;
27+
font-style: normal;
28+
}
29+
30+
.e-grid .e-icon-userlogin::before {
31+
font-family: 'ej2-headertemplate';
32+
content: '\e702';
33+
}
34+
35+
.e-grid .e-icon-calendar::before {
36+
font-family: 'ej2-headertemplate';
37+
content: '\e960';
38+
}
39+
40+
.image img {
41+
height: 55px;
42+
width: 55px;
43+
border-radius: 50px;
44+
box-shadow: inset 0 0 1px #e0e0e0, inset 0 0 14px rgba(0, 0, 0, 0.2);
45+
}
46+
</style>
47+
48+
<script id="datatemplate" type="text/x-template">
49+
<div class="image">
50+
<img src="@Url.Content("~/Images/data-grid/${EmployeeID}.png")"/>
51+
</div>
52+
</script>
53+
54+
<script id="conditionaltemplate" type="text/x-template">
55+
<div>
56+
${if(Discontinued)}
57+
<input type="checkbox" checked> ${else}
58+
<input type="checkbox">
59+
${/if}
60+
</div>
61+
</script>
62+
63+
<script id="employeetemplate" type="text/x-template">
64+
<span class="e-icon-userlogin"> Employee ID </span>
65+
</script>
66+
67+
<script id="datetemplate" type="text/x-template">
68+
<span class="e-icon-calendar"> Date Joined </span>
69+
</script>
70+
71+
72+
73+

Pages/Index.cshtml.cs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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, bool Discontinued)
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+
this.Discontinued = Discontinued;
24+
}
25+
public int EmployeeID { get; set; }
26+
public string FirstName { get; set; }
27+
public string LastName { get; set; }
28+
public string Title { get; set; }
29+
public DateTime BirthDate { get; set; }
30+
public DateTime HireDate { get; set; }
31+
public int ReportsTo { get; set; }
32+
public string Address { get; set; }
33+
public string PostalCode { get; set; }
34+
public string Phone { get; set; }
35+
public string City { get; set; }
36+
public string Country { get; set; }
37+
public string Email { get; set; }
38+
public bool Discontinued { get; set; }
39+
public static List<Employee> GetAllRecords()
40+
{
41+
List<Employee> Emp = new List<Employee>();
42+
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", true));
43+
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", true));
44+
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", false));
45+
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", true));
46+
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", true));
47+
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", false));
48+
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", true));
49+
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", true));
50+
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", false));
51+
return Emp;
52+
}
53+
}
54+
55+
public class IndexModel : PageModel
56+
{
57+
public void OnGet()
58+
{
59+
60+
}
61+
}
62+
}

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)