DmitrMakeev commited on
Commit
2020f0d
·
verified ·
1 Parent(s): 0a59d2d

Update data_gc_tab.html

Browse files
Files changed (1) hide show
  1. data_gc_tab.html +32 -26
data_gc_tab.html CHANGED
@@ -162,9 +162,11 @@
162
 
163
  <button id="filter-clear">Очистить фильтр</button>
164
 
165
- <button id="download-json">Скачать JSON</button>
166
- <button id="download-pdf">Скачать PDF</button>
167
- <button id="download-csv">Скачать CSV</button>
 
 
168
  </div>
169
  <div id="example-table"></div>
170
 
@@ -262,29 +264,33 @@
262
  valueEl.value = "";
263
  table.clearFilter();
264
  });
265
- // Handle button click for downloading JSON
266
- document.getElementById("download-json").addEventListener("click", function() {
267
- var tableData = table.getData(); // Получаем все данные таблицы
268
- var jsonData = JSON.stringify(tableData, null, 2); // Преобразуем данные в JSON-строку
269
- var blob = new Blob([jsonData], {type: "application/json"});
270
- var url = URL.createObjectURL(blob);
271
- var a = document.createElement("a");
272
- a.href = url;
273
- a.download = "data.json";
274
- a.click();
275
- URL.revokeObjectURL(url);
276
- });
277
- // Handle button click for downloading PDF
278
- document.getElementById("download-pdf").addEventListener("click", function() {
279
- table.download("pdf", "data.pdf", {
280
- orientation:"portrait", //set page orientation to portrait
281
- title:"Example Report" //add title to report
282
- });
283
- });
284
- // Handle button click for downloading CSV
285
- document.getElementById("download-csv").addEventListener("click", function() {
286
- table.download("csv", "data.csv");
287
- });
 
 
 
 
288
  })
289
  .catch(error => console.error('Error fetching data:', error));
290
  });
 
162
 
163
  <button id="filter-clear">Очистить фильтр</button>
164
 
165
+ <button id="download-csv">Download CSV</button>
166
+ <button id="download-json">Download JSON</button>
167
+ <button id="download-xlsx">Download XLSX</button>
168
+ <button id="download-pdf">Download PDF</button>
169
+ <button id="download-html">Download HTML</button>
170
  </div>
171
  <div id="example-table"></div>
172
 
 
264
  valueEl.value = "";
265
  table.clearFilter();
266
  });
267
+ //trigger download of data.csv file
268
+ document.getElementById("download-csv").addEventListener("click", function(){
269
+ table.download("csv", "data.csv");
270
+ });
271
+
272
+ //trigger download of data.json file
273
+ document.getElementById("download-json").addEventListener("click", function(){
274
+ table.download("json", "data.json");
275
+ });
276
+
277
+ //trigger download of data.xlsx file
278
+ document.getElementById("download-xlsx").addEventListener("click", function(){
279
+ table.download("xlsx", "data.xlsx", {sheetName:"My Data"});
280
+ });
281
+
282
+ //trigger download of data.pdf file
283
+ document.getElementById("download-pdf").addEventListener("click", function(){
284
+ table.download("pdf", "data.pdf", {
285
+ orientation:"portrait", //set page orientation to portrait
286
+ title:"Example Report", //add title to report
287
+ });
288
+ });
289
+
290
+ //trigger download of data.html file
291
+ document.getElementById("download-html").addEventListener("click", function(){
292
+ table.download("html", "data.html", {style:true});
293
+ });
294
  })
295
  .catch(error => console.error('Error fetching data:', error));
296
  });