Skip to content

Commit 59fca3b

Browse files
committed
documentation(EJ2-67661): UG document to save and load report using database.
1 parent d76a460 commit 59fca3b

3 files changed

Lines changed: 68 additions & 68 deletions

File tree

Core/PivotTable/Views/Home/Index.cshtml

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -30,109 +30,109 @@
3030
</e-chartSettings>
3131
</ejs-pivotview>
3232

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) {
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) {
4040
reportListObj[0].dataSource = reportList;
4141
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-
}
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] })
4847
}
4948
}
50-
function saveReport(args) {
51-
var report = JSON.parse(args.report);
52-
report.dataSourceSettings.dataSource = [];
53-
fetch('https://localhost:44313/Pivot/SaveReport', {
49+
}
50+
function saveReport(args) {
51+
var report = JSON.parse(args.report);
52+
report.dataSourceSettings.dataSource = [];
53+
fetch('https://localhost:44313/Pivot/SaveReport', {
5454
method: 'POST',
5555
headers: {
5656
'Accept': 'application/json',
5757
'Content-Type': 'application/json',
5858
},
5959
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', {
60+
}).then(response => {
61+
fetchReport(args);
62+
});
63+
}
64+
function fetchReport(args) {
65+
fetch('https://localhost:44313/Pivot/FetchReport', {
6666
method: 'POST',
6767
headers: {
6868
'Accept': 'application/json',
6969
'Content-Type': 'application/json',
7070
},
7171
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', {
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', {
7979
method: 'POST',
8080
headers: {
8181
'Accept': 'application/json',
8282
'Content-Type': 'application/json',
8383
},
8484
body: JSON.stringify({ reportName: args.reportName })
85-
}).then(res => res.json())
86-
.then(response => {
87-
if (response) {
85+
}).then(res => res.json())
86+
.then(response => {
87+
if (response) {
8888
var report = JSON.parse(response);
8989
var pivotTableObj = document.getElementById('pivotview').ej2_instances[0];
9090
report.dataSourceSettings.dataSource = pivotTableObj.dataSourceSettings.dataSource;
9191
pivotTableObj.dataSourceSettings = report.dataSourceSettings;
92-
}
93-
});
94-
}
95-
function removeReport(args) {
96-
fetch('https://localhost:44313/Pivot/RemoveReport', {
92+
}
93+
});
94+
}
95+
function removeReport(args) {
96+
fetch('https://localhost:44313/Pivot/RemoveReport', {
9797
method: 'POST',
9898
headers: {
9999
'Accept': 'application/json',
100100
'Content-Type': 'application/json',
101101
},
102102
body: JSON.stringify({ reportName: args.reportName })
103-
}).then(response => {
103+
}).then(response => {
104104
fetchReport(args);
105-
});
106-
}
107-
function renameReport(args) {
108-
fetch('https://localhost:44313/Pivot/RenameReport', {
105+
});
106+
}
107+
function renameReport(args) {
108+
fetch('https://localhost:44313/Pivot/RenameReport', {
109109
method: 'POST',
110110
headers: {
111111
'Accept': 'application/json',
112112
'Content-Type': 'application/json',
113113
},
114114
body: JSON.stringify({ reportName: args.reportName, renameReport: args.rename, isReportExists: args.isReportExists })
115-
}).then(response => {
115+
}).then(response => {
116116
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>
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>

Core/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ Before beginning work on the server and client projects, ensure the following so
1515

1616
* To run this application, clone the [Save-and-load-report-from-SQL-database-to-pivot-table](https://github.com/SyncfusionExamples/Save-and-load-report-from-SQL-database-to-pivot-table) repository and then open **MyWebService** in Visual Studio 2022. Simply build and run your project in IIS Express, and it will host and display the URL `https://localhost:44313`.
1717

18-
* Now open ASP.NET Core sample in Visual Studio. Initialize the Pivot Table, map the hosted URL, create a pivot report, and finally, build and run your project in IIS Express to achieve the desired result.
18+
* Now open ASP.NET Core sample in Visual Studio. Initialize the Pivot Table, create a pivot report based on the given data source, map the hosted url to perform save and load reports with the SQL database. finally, build and run your project in IIS Express to achieve the desired result.

MVC/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ Before beginning work on the server and client projects, ensure the following so
1515

1616
* To run this application, clone the [Save-and-load-report-from-SQL-database-to-pivot-table](https://github.com/SyncfusionExamples/Save-and-load-report-from-SQL-database-to-pivot-table) repository and then open **MyWebService** in Visual Studio 2022. Simply build and run your project in IIS Express, and it will host and display the URL `https://localhost:44313`.
1717

18-
* Now open ASP.NET MVC sample in Visual Studio. Initialize the Pivot Table, map the hosted URL, create a pivot report, and finally, build and run your project in IIS Express to achieve the desired result.
18+
* Now open ASP.NET MVC sample in Visual Studio. Initialize the Pivot Table, create a pivot report based on the given data source, map the hosted url to perform save and load reports with the SQL database. finally, build and run your project in IIS Express to achieve the desired result.

0 commit comments

Comments
 (0)