Skip to content

Commit 05b2253

Browse files
authored
Merge pull request #4 from Yash58vanth/master
documentation(EJ2-67661): UG document to save and load report using database.
2 parents 1daf562 + d4b1183 commit 05b2253

File tree

128 files changed

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

128 files changed

+415902
-0
lines changed

Core/PivotTable/Controllers/HomeController.cs

Lines changed: 196 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace PivotTable.Models
2+
{
3+
public class PivotData
4+
{
5+
public int Sold { get; set; }
6+
public int In_Stock { get; set; }
7+
public double Amount { get; set; }
8+
public string Country { get; set; }
9+
public string Product_Categories { get; set; }
10+
public string Products { get; set; }
11+
public string Order_Source { get; set; }
12+
public string Year { get; set; }
13+
public string Quarter { get; set; }
14+
}
15+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace PivotTable.Models
2+
{
3+
public class ErrorViewModel
4+
{
5+
public string? RequestId { get; set; }
6+
7+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System.Collections.Generic;
2+
3+
namespace PivotTable.Models
4+
{
5+
public class PivotModel
6+
{
7+
public List<PivotData> PivotData { get; set; }
8+
}
9+
}

Core/PivotTable/PivotTable.csproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="20.4.0.44" />
11+
</ItemGroup>
12+
13+
</Project>

Core/PivotTable/PivotTable.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.3.32929.385
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PivotTable", "PivotTable.csproj", "{8E6FC135-C046-48D6-8782-DCA417D73F3F}"
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+
{8E6FC135-C046-48D6-8782-DCA417D73F3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{8E6FC135-C046-48D6-8782-DCA417D73F3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{8E6FC135-C046-48D6-8782-DCA417D73F3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{8E6FC135-C046-48D6-8782-DCA417D73F3F}.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 = {8082EC2C-C16D-4459-A466-4743CD3F37BE}
24+
EndGlobalSection
25+
EndGlobal

Core/PivotTable/Program.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var builder = WebApplication.CreateBuilder(args);
2+
3+
// Add services to the container.
4+
builder.Services.AddControllersWithViews();
5+
6+
var app = builder.Build();
7+
8+
// Configure the HTTP request pipeline.
9+
if (!app.Environment.IsDevelopment())
10+
{
11+
app.UseExceptionHandler("/Home/Error");
12+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
13+
app.UseHsts();
14+
}
15+
16+
app.UseHttpsRedirection();
17+
app.UseStaticFiles();
18+
19+
app.UseRouting();
20+
21+
app.UseAuthorization();
22+
23+
app.MapControllerRoute(
24+
name: "default",
25+
pattern: "{controller=Home}/{action=Index}/{id?}");
26+
27+
app.Run();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:37493",
7+
"sslPort": 44355
8+
}
9+
},
10+
"profiles": {
11+
"PivotTable": {
12+
"commandName": "Project",
13+
"dotnetRunMessages": true,
14+
"launchBrowser": true,
15+
"applicationUrl": "https://localhost:7169;http://localhost:5169",
16+
"environmentVariables": {
17+
"ASPNETCORE_ENVIRONMENT": "Development"
18+
}
19+
},
20+
"IIS Express": {
21+
"commandName": "IISExpress",
22+
"launchBrowser": true,
23+
"environmentVariables": {
24+
"ASPNETCORE_ENVIRONMENT": "Development"
25+
}
26+
}
27+
}
28+
}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
@{
2+
ViewData["Title"] = "Home Page";
3+
}
4+
5+
<ejs-pivotview id="pivotview" allowExcelExport="true" allowConditionalFormatting="true" allowPdfExport="true" showToolbar="true" allowCalculatedField="true" showFieldList="true" width="700" toolbar="@(new List<string>() {"New", "Save", "SaveAs", "Rename", "Remove", "Load",
6+
"Grid", "Chart", "Export", "SubTotal", "GrandTotal", "Formatting", "FieldList" })" saveReport="saveReport" loadReport="loadReport" fetchReport="fetchReport" renameReport="renameReport" removeReport="removeReport" newReport="newReport" toolbarRender="beforeToolbarRender">
7+
<e-datasourcesettings dataSource="@ViewBag.data" expandAll="false">
8+
<e-formatsettings>
9+
<e-field name="Amount" format="C0"></e-field>
10+
</e-formatsettings>
11+
<e-rows>
12+
<e-field name="Country"></e-field>
13+
<e-field name="Products"></e-field>
14+
</e-rows>
15+
<e-columns>
16+
<e-field name="Year" caption="Production Year"></e-field>
17+
<e-field name="Quarter"></e-field>
18+
</e-columns>
19+
<e-values>
20+
<e-field name="Sold" caption="Units Sold"></e-field>
21+
<e-field name="Amount" caption="Sold Amount"></e-field>
22+
</e-values>
23+
<e-filters>
24+
<e-field></e-field>
25+
</e-filters>
26+
</e-datasourcesettings>
27+
<e-displayOption view="Both"></e-displayOption>
28+
<e-chartSettings value="Amount" enableExport="true" enableMultipleAxis="false">
29+
<e-chartSeries type="Column"></e-chartSeries>
30+
</e-chartSettings>
31+
</ejs-pivotview>
32+
33+
<script>
34+
function updateReport(reportList) {
35+
var pivotTableObj = document.getElementById('pivotview').ej2_instances[0];
36+
// Here you can refresh the report list by feeding updated reports fetched from the database.
37+
var reportListObj = pivotTableObj.element.querySelector(
38+
"#" + pivotTableObj.element.id + "_reportlist").ej2_instances;
39+
if (reportListObj) {
40+
reportListObj[0].dataSource = reportList;
41+
reportListObj[0].value = pivotTableObj.toolbarModule.currentReport;
42+
// For remove report
43+
if (pivotTableObj.toolbarModule.currentReport === "" && (reportListObj[0].itemData === null || reportList.length < 2)) {
44+
pivotTableObj.toolbarModule.currentReport = reportList[reportList.length - 1];
45+
reportListObj[0].value = pivotTableObj.toolbarModule.currentReport;
46+
loadReport({ reportName: reportList[reportList.length - 1] })
47+
}
48+
}
49+
}
50+
function saveReport(args) {
51+
var report = JSON.parse(args.report);
52+
report.dataSourceSettings.dataSource = [];
53+
fetch('https://localhost:44313/Pivot/SaveReport', {
54+
method: 'POST',
55+
headers: {
56+
'Accept': 'application/json',
57+
'Content-Type': 'application/json',
58+
},
59+
body: JSON.stringify({ reportName: args.reportName, report: JSON.stringify(report) })
60+
}).then(response => {
61+
fetchReport(args);
62+
});
63+
}
64+
function fetchReport(args) {
65+
fetch('https://localhost:44313/Pivot/FetchReport', {
66+
method: 'POST',
67+
headers: {
68+
'Accept': 'application/json',
69+
'Content-Type': 'application/json',
70+
},
71+
body: ""
72+
}).then(res => res.json())
73+
.then(response => {
74+
updateReport(response.length > 0 ? response : []);
75+
});
76+
}
77+
function loadReport(args) {
78+
fetch('https://localhost:44313/Pivot/LoadReport', {
79+
method: 'POST',
80+
headers: {
81+
'Accept': 'application/json',
82+
'Content-Type': 'application/json',
83+
},
84+
body: JSON.stringify({ reportName: args.reportName })
85+
}).then(res => res.json())
86+
.then(response => {
87+
if (response) {
88+
var report = JSON.parse(response);
89+
var pivotTableObj = document.getElementById('pivotview').ej2_instances[0];
90+
report.dataSourceSettings.dataSource = pivotTableObj.dataSourceSettings.dataSource;
91+
pivotTableObj.dataSourceSettings = report.dataSourceSettings;
92+
}
93+
});
94+
}
95+
function removeReport(args) {
96+
fetch('https://localhost:44313/Pivot/RemoveReport', {
97+
method: 'POST',
98+
headers: {
99+
'Accept': 'application/json',
100+
'Content-Type': 'application/json',
101+
},
102+
body: JSON.stringify({ reportName: args.reportName })
103+
}).then(response => {
104+
fetchReport(args);
105+
});
106+
}
107+
function renameReport(args) {
108+
fetch('https://localhost:44313/Pivot/RenameReport', {
109+
method: 'POST',
110+
headers: {
111+
'Accept': 'application/json',
112+
'Content-Type': 'application/json',
113+
},
114+
body: JSON.stringify({ reportName: args.reportName, renameReport: args.rename, isReportExists: args.isReportExists })
115+
}).then(response => {
116+
fetchReport(args);
117+
});
118+
}
119+
function newReport() {
120+
var pivotTableObj = document.getElementById('pivotview').ej2_instances[0];
121+
pivotTableObj.setProperties({
122+
dataSourceSettings: {
123+
columns: [],
124+
rows: [],
125+
values: [],
126+
filters: []
127+
}
128+
}, false);
129+
}
130+
function beforeToolbarRender(args) {
131+
args.customToolbar.splice(6, 0, {
132+
type: 'Separator'
133+
});
134+
args.customToolbar.splice(9, 0, {
135+
type: 'Separator'
136+
});
137+
}
138+
</script>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@{
2+
ViewData["Title"] = "Privacy Policy";
3+
}
4+
<h1>@ViewData["Title"]</h1>
5+
6+
<p>Use this page to detail your site's privacy policy.</p>

0 commit comments

Comments
 (0)