Skip to content

Commit 76ed380

Browse files
Merge pull request #2 from Backiaraj/grid
Updated .net 5.0 framework sample
2 parents d7e6b0b + 6b3d97c commit 76ed380

Some content is hidden

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

41 files changed

+2618
-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.31729.503
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Validation_GridDialogTemplate", "Validation_GridDialogTemplate\Validation_GridDialogTemplate.csproj", "{2EDA9711-A6DF-4CB0-B9C8-829C9F9D7EF5}"
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+
{2EDA9711-A6DF-4CB0-B9C8-829C9F9D7EF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{2EDA9711-A6DF-4CB0-B9C8-829C9F9D7EF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{2EDA9711-A6DF-4CB0-B9C8-829C9F9D7EF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{2EDA9711-A6DF-4CB0-B9C8-829C9F9D7EF5}.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 = {C095E611-4C56-476C-BC1C-04673467D5C5}
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 Validation_GridDialogTemplate.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 Validation_GridDialogTemplate.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: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
@page "/datagrid-features"
2+
3+
@using Syncfusion.Blazor.Grids
4+
@using Syncfusion.Blazor.Calendars
5+
@using Syncfusion.Blazor.DropDowns
6+
@using Syncfusion.Blazor.Inputs
7+
@using System.ComponentModel.DataAnnotations
8+
<SfGrid DataSource="@GridData" Toolbar="@(new string[] {"Add", "Edit" ,"Delete","Update","Cancel" })">
9+
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="@EditMode.Dialog">
10+
<Validator>
11+
<DataAnnotationsValidator></DataAnnotationsValidator>
12+
</Validator>
13+
<Template>
14+
@{
15+
var Order = (context as OrdersDetails);
16+
<div>
17+
<ValidationMessage For="() => Order.ShipCountry" />
18+
<ValidationMessage For="() => Order.ShipAddress" />
19+
<div class="form-row">
20+
<div class="form-group col-md-6">
21+
<label class="e-float-text e-label-top">Order ID</label>
22+
<SfNumericTextBox ID="OrderID" @bind-Value="@(Order.OrderID)" Enabled="@((Order.OrderID == null) ? true : false)"></SfNumericTextBox>
23+
</div>
24+
<div class="form-group col-md-6">
25+
<label class="e-float-text e-label-top">Customer Name</label>
26+
<SfAutoComplete ID="customerID" TItem="OrdersDetails" @bind-Value="@(Order.CustomerID)" TValue="string" DataSource="@GridData">
27+
<AutoCompleteFieldSettings Value="CustomerID"></AutoCompleteFieldSettings>
28+
</SfAutoComplete>
29+
</div>
30+
</div>
31+
<div class="form-row">
32+
<div class="form-group col-md-6">
33+
<label class="e-float-text e-label-top">Freight</label>
34+
<SfNumericTextBox ID="Freight" @bind-Value="@(Order.Freight)" TValue="double?"></SfNumericTextBox>
35+
</div>
36+
<div class="form-group col-md-6">
37+
<label class="e-float-text e-label-top">Order Date</label>
38+
<SfDatePicker ID="OrderDate" @bind-Value="@(Order.OrderDate)"></SfDatePicker>
39+
</div>
40+
</div>
41+
<div class="form-row">
42+
<div class="form-group col-md-6">
43+
<label class="e-float-text e-label-top">Ship Country</label>
44+
<SfDropDownList ID="ShipCountry" @bind-Value="@(Order.ShipCountry)" TItem="OrdersDetails" TValue="string" DataSource="@GridData">
45+
<DropDownListFieldSettings Value="ShipCountry" Text="ShipCountry"></DropDownListFieldSettings>
46+
</SfDropDownList>
47+
</div>
48+
<div class="form-group col-md-6">
49+
<label class="e-float-text e-label-top">Ship City</label>
50+
<SfDropDownList ID="ShipCity" @bind-Value="@(Order.ShipCity)" TItem="OrdersDetails" TValue="string" DataSource="@GridData">
51+
<DropDownListFieldSettings Value="ShipCity" Text="ShipCity"></DropDownListFieldSettings>
52+
</SfDropDownList>
53+
</div>
54+
</div>
55+
<div class="form-row">
56+
<div class="form-group col-md-12">
57+
<label class="e-float-text e-label-top">Ship Address</label>
58+
<SfTextBox ID="ShipAddress" @bind-Value="@(Order.ShipAddress)"></SfTextBox>
59+
</div>
60+
</div>
61+
</div>
62+
}
63+
</Template>
64+
</GridEditSettings>
65+
<GridColumns>
66+
<GridColumn Field=@nameof(OrdersDetails.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="@TextAlign.Center" HeaderTextAlign="@TextAlign.Center" Width="140"></GridColumn>
67+
<GridColumn Field=@nameof(OrdersDetails.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>
68+
<GridColumn Field=@nameof(OrdersDetails.Freight) HeaderText="Freight" Format="C2" Width="140" TextAlign="@TextAlign.Right" HeaderTextAlign="@TextAlign.Right"></GridColumn>
69+
<GridColumn Field=@nameof(OrdersDetails.OrderDate) HeaderText="Order Date" Format="d" Type="ColumnType.Date" Width="160"></GridColumn>
70+
<GridColumn Field=@nameof(OrdersDetails.ShipCountry) HeaderText="Ship Country" Width="150"></GridColumn>
71+
</GridColumns>
72+
</SfGrid>
73+
@code{
74+
public List<OrdersDetails> GridData = new List<OrdersDetails>
75+
{
76+
new OrdersDetails() { OrderID = 10248, CustomerID = "VINET", Freight = 32.38, ShipCity = "Berlin", OrderDate = DateTime.Now.AddDays(-2), ShipName = "Vins et alcools Chevalier", ShipCountry = "Denmark", ShipAddress = "Kirchgasse 6" },
77+
new OrdersDetails() { OrderID = 10249, CustomerID = "TOMSP", Freight = 11.61, ShipCity = "Madrid", OrderDate = DateTime.Now.AddDays(-5), ShipName = "Toms Spezialitäten", ShipCountry = "Brazil", ShipAddress = "Avda. Azteca 123" },
78+
new OrdersDetails() { OrderID = 10250, CustomerID = "HANAR", Freight = 65.83, ShipCity = "Cholchester", OrderDate = DateTime.Now.AddDays(-12), ShipName = "Hanari Carnes", ShipCountry = "Germany", ShipAddress = "Carrera 52 con Ave. Bolívar #65-98 Llano Largo" },
79+
new OrdersDetails() { OrderID = 10251, CustomerID = "VICTE", Freight = 41.34, ShipCity = "Marseille", OrderDate = DateTime.Now.AddDays(-18), ShipName = "Victuailles en stock", ShipCountry = "Austria", ShipAddress = "Magazinweg 7" },
80+
new OrdersDetails() { OrderID = 10252, CustomerID = "SUPRD", Freight = 51.3, ShipCity = "Tsawassen", OrderDate = DateTime.Now.AddDays(-22), ShipName = "Suprêmes délices", ShipCountry = "Switzerland", ShipAddress = "1029 - 12th Ave. S." },
81+
new OrdersDetails() { OrderID = 10253, CustomerID = "HANAR", Freight = 58.17, ShipCity = "Tsawassen", OrderDate = DateTime.Now.AddDays(-26), ShipName = "Hanari Carnes", ShipCountry = "Switzerland", ShipAddress = "1029 - 12th Ave. S." },
82+
new OrdersDetails() { OrderID = 10254, CustomerID = "CHOPS", Freight = 22.98, ShipCity = "Berlin", OrderDate = DateTime.Now.AddDays(-34), ShipName = "Chop-suey Chinese", ShipCountry = "Denmark", ShipAddress = "Kirchgasse 6" },
83+
new OrdersDetails() { OrderID = 10255, CustomerID = "RICSU", Freight = 148.33, ShipCity = "Madrid", OrderDate = DateTime.Now.AddDays(-39), ShipName = "Richter Supermarket", ShipCountry = "Brazil", ShipAddress = "Avda. Azteca 123" },
84+
new OrdersDetails() { OrderID = 10256, CustomerID = "WELLI", Freight = 13.97, ShipCity = "Madrid", OrderDate = DateTime.Now.AddDays(-43), ShipName = "Wellington Importadora", ShipCountry = "Brazil", ShipAddress = "Avda. Azteca 123" },
85+
new OrdersDetails() { OrderID = 10257, CustomerID = "HILAA", Freight = 81.91, ShipCity = "Cholchester", OrderDate = DateTime.Now.AddDays(-48), ShipName = "HILARION-Abastos", ShipCountry = "Germany", ShipAddress = "Carrera 52 con Ave. Bolívar #65-98 Llano Largo" }
86+
};
87+
public class OrdersDetails
88+
{
89+
public int? OrderID { get; set; }
90+
public string CustomerID { get; set; }
91+
public double? Freight { get; set; }
92+
public string ShipCity { get; set; }
93+
public DateTime OrderDate { get; set; }
94+
public string ShipName { get; set; }
95+
[Required]
96+
public string ShipCountry { get; set; }
97+
[Required]
98+
public string ShipAddress { get; set; }
99+
}
100+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@page
2+
@model Validation_GridDialogTemplate.Pages.ErrorModel
3+
4+
<!DOCTYPE html>
5+
<html>
6+
7+
<head>
8+
<meta charset="utf-8" />
9+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
10+
<title>Error</title>
11+
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
12+
<link href="~/css/app.css" rel="stylesheet" />
13+
</head>
14+
15+
<body>
16+
<div class="main">
17+
<div class="content px-4">
18+
<h1 class="text-danger">Error.</h1>
19+
<h2 class="text-danger">An error occurred while processing your request.</h2>
20+
21+
@if (Model.ShowRequestId)
22+
{
23+
<p>
24+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
25+
</p>
26+
}
27+
28+
<h3>Development Mode</h3>
29+
<p>
30+
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
31+
</p>
32+
<p>
33+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
34+
It can result in displaying sensitive information from exceptions to end users.
35+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
36+
and restarting the app.
37+
</p>
38+
</div>
39+
</div>
40+
</body>
41+
42+
</html>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
using Microsoft.Extensions.Logging;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Diagnostics;
7+
using System.Linq;
8+
using System.Threading.Tasks;
9+
10+
namespace Validation_GridDialogTemplate.Pages
11+
{
12+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
13+
[IgnoreAntiforgeryToken]
14+
public class ErrorModel : PageModel
15+
{
16+
public string RequestId { get; set; }
17+
18+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
19+
20+
private readonly ILogger<ErrorModel> _logger;
21+
22+
public ErrorModel(ILogger<ErrorModel> logger)
23+
{
24+
_logger = logger;
25+
}
26+
27+
public void OnGet()
28+
{
29+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
30+
}
31+
}
32+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
@page "/"
2+
3+
<span class="pageheader">Selected Controls</span>
4+
<br />
5+
<p class="pagecontent">The following Syncfusion Blazor components can be set up in an application for you with the Syncfusion Blazor Template Studio. A fast, easy start with Syncfusion Blazor components lets you concentrate on the important part: learning.</p>
6+
<div class="controlregion">
7+
8+
<h5 class="productheader"> Grids</h5>
9+
<ul class="ulstyle">
10+
<li class="list">
11+
<NavLink class="nav-link" href="datagrid-features">
12+
<span class="syncfusion-blazor-index-icons syncfusion-blazor-icon-datagrid" aria-hidden="true"></span>DataGrid
13+
</NavLink>
14+
</li>
15+
16+
</ul>
17+
18+
</div>
19+
<style>
20+
.ulstyle {
21+
margin-top: 10px;
22+
margin-bottom: 20px;
23+
display: inline-block;
24+
list-style-type: none !important;
25+
padding-left: 0px !important;
26+
}
27+
28+
.controlregion {
29+
margin-top: 50px;
30+
}
31+
32+
.pagecontent {
33+
font-family: sans-serif !important;
34+
font-size: 16px;
35+
color: #333333;
36+
letter-spacing: 0.34px;
37+
line-height: 24px;
38+
margin-top: 10px;
39+
}
40+
41+
42+
.list {
43+
float: left;
44+
line-height: 40px;
45+
min-width: 280px;
46+
font-family: sans-serif !important;
47+
font-size: 19px;
48+
color: #0073DC;
49+
}
50+
51+
.syncfusion-blazor-index-icons {
52+
font-family: "sbicons";
53+
color: #0073DC !important;
54+
font-style: normal;
55+
font-weight: normal;
56+
font-variant: normal;
57+
text-transform: none;
58+
padding-right: 13px;
59+
font-size: 18px;
60+
}
61+
62+
.productheader {
63+
font-family: sans-serif !important;
64+
font-size: 19px !important;
65+
color: #333333 !important;
66+
letter-spacing: 0.41px ;
67+
}
68+
69+
.pageheader {
70+
font-family: sans-serif !important;
71+
font-size: 24px !important;
72+
color: #333333 ;
73+
font-weight: bold !important;
74+
}
75+
</style>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
@page "/"
2+
@namespace Validation_GridDialogTemplate.Pages
3+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4+
@{
5+
Layout = null;
6+
}
7+
8+
<!DOCTYPE html>
9+
<html lang="en">
10+
<head>
11+
<meta charset="utf-8" />
12+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
13+
<title>Validation_GridDialogTemplate</title>
14+
<base href="~/" />
15+
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
16+
<link href="css/site.css" rel="stylesheet" />
17+
<link href="Validation_GridDialogTemplate.styles.css" rel="stylesheet" />
18+
<link href="css/syncfusion-blazor-icons.css" rel="stylesheet" />
19+
<link href="https://cdn.syncfusion.com/blazor/20.1.50/styles/fluent.css" rel="stylesheet" />
20+
<link rel="stylesheet" href="_content/Syncfusion.Blazor.Themes/bootstrap4.css" />
21+
</head>
22+
<body>
23+
<component type="typeof(App)" render-mode="ServerPrerendered" />
24+
25+
<div id="blazor-error-ui">
26+
<environment include="Staging,Production">
27+
An error has occurred. This application may no longer respond until reloaded.
28+
</environment>
29+
<environment include="Development">
30+
An unhandled exception has occurred. See browser dev tools for details.
31+
</environment>
32+
<a href="" class="reload">Reload</a>
33+
<a class="dismiss">🗙</a>
34+
</div>
35+
36+
<script src="_framework/blazor.server.js"></script>
37+
<script src="https://cdn.syncfusion.com/blazor/20.1.50/syncfusion-blazor.min.js" type="text/javascript"></script>
38+
<script>
39+
function isSidebar(x, y) {
40+
var sidebarEle = document.elementFromPoint(x, y);
41+
return (sidebarEle && sidebarEle.closest('.sidebar') != null) ? true : false;
42+
}
43+
</script>
44+
</body>
45+
</html>

0 commit comments

Comments
 (0)