|
30 | 30 | </e-chartSettings> |
31 | 31 | </ejs-pivotview> |
32 | 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) { |
| 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 | 40 | reportListObj[0].dataSource = reportList; |
41 | 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 | | - } |
| 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] }) |
48 | 47 | } |
49 | 48 | } |
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', { |
54 | 54 | method: 'POST', |
55 | 55 | headers: { |
56 | 56 | 'Accept': 'application/json', |
57 | 57 | 'Content-Type': 'application/json', |
58 | 58 | }, |
59 | 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', { |
| 60 | + }).then(response => { |
| 61 | + fetchReport(args); |
| 62 | + }); |
| 63 | + } |
| 64 | + function fetchReport(args) { |
| 65 | + fetch('https://localhost:44313/Pivot/FetchReport', { |
66 | 66 | method: 'POST', |
67 | 67 | headers: { |
68 | 68 | 'Accept': 'application/json', |
69 | 69 | 'Content-Type': 'application/json', |
70 | 70 | }, |
71 | 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', { |
| 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 | 79 | method: 'POST', |
80 | 80 | headers: { |
81 | 81 | 'Accept': 'application/json', |
82 | 82 | 'Content-Type': 'application/json', |
83 | 83 | }, |
84 | 84 | 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) { |
88 | 88 | var report = JSON.parse(response); |
89 | 89 | var pivotTableObj = document.getElementById('pivotview').ej2_instances[0]; |
90 | 90 | report.dataSourceSettings.dataSource = pivotTableObj.dataSourceSettings.dataSource; |
91 | 91 | 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', { |
97 | 97 | method: 'POST', |
98 | 98 | headers: { |
99 | 99 | 'Accept': 'application/json', |
100 | 100 | 'Content-Type': 'application/json', |
101 | 101 | }, |
102 | 102 | body: JSON.stringify({ reportName: args.reportName }) |
103 | | - }).then(response => { |
| 103 | + }).then(response => { |
104 | 104 | 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', { |
109 | 109 | method: 'POST', |
110 | 110 | headers: { |
111 | 111 | 'Accept': 'application/json', |
112 | 112 | 'Content-Type': 'application/json', |
113 | 113 | }, |
114 | 114 | body: JSON.stringify({ reportName: args.reportName, renameReport: args.rename, isReportExists: args.isReportExists }) |
115 | | - }).then(response => { |
| 115 | + }).then(response => { |
116 | 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> |
| 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> |
0 commit comments