DmitrMakeev
commited on
Update data_gc_tab.html
Browse files- data_gc_tab.html +25 -19
data_gc_tab.html
CHANGED
@@ -163,7 +163,9 @@
|
|
163 |
|
164 |
<button id="filter-clear">Очистить фильтр</button>
|
165 |
|
166 |
-
<
|
|
|
|
|
167 |
</div>
|
168 |
<div id="example-table"></div>
|
169 |
|
@@ -242,7 +244,6 @@
|
|
242 |
var fieldEl = document.getElementById("filter-field");
|
243 |
var typeEl = document.getElementById("filter-type");
|
244 |
var valueEl = document.getElementById("filter-value");
|
245 |
-
var selectFilteredDataCheckbox = document.getElementById("select-filtered-data-checkbox");
|
246 |
// Trigger setFilter function with correct parameters
|
247 |
function updateFilter() {
|
248 |
var filterVal = fieldEl.options[fieldEl.selectedIndex].value;
|
@@ -250,12 +251,6 @@
|
|
250 |
if (filterVal) {
|
251 |
table.setFilter(filterVal, typeVal, valueEl.value);
|
252 |
}
|
253 |
-
if (selectFilteredDataCheckbox.checked) {
|
254 |
-
var filteredData = table.getData("filtered");
|
255 |
-
var jsonData = JSON.stringify(filteredData);
|
256 |
-
window.filteredDataJSON = jsonData;
|
257 |
-
console.log("Отфильтрованные данные преобразованы в JSON:", jsonData);
|
258 |
-
}
|
259 |
}
|
260 |
// Update filters on value change
|
261 |
document.getElementById("filter-field").addEventListener("change", updateFilter);
|
@@ -268,17 +263,28 @@
|
|
268 |
valueEl.value = "";
|
269 |
table.clearFilter();
|
270 |
});
|
271 |
-
// Handle
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
});
|
283 |
})
|
284 |
.catch(error => console.error('Error fetching data:', error));
|
|
|
163 |
|
164 |
<button id="filter-clear">Очистить фильтр</button>
|
165 |
|
166 |
+
<button id="download-json">Скачать JSON</button>
|
167 |
+
<button id="download-pdf">Скачать PDF</button>
|
168 |
+
<button id="download-csv">Скачать CSV</button>
|
169 |
</div>
|
170 |
<div id="example-table"></div>
|
171 |
|
|
|
244 |
var fieldEl = document.getElementById("filter-field");
|
245 |
var typeEl = document.getElementById("filter-type");
|
246 |
var valueEl = document.getElementById("filter-value");
|
|
|
247 |
// Trigger setFilter function with correct parameters
|
248 |
function updateFilter() {
|
249 |
var filterVal = fieldEl.options[fieldEl.selectedIndex].value;
|
|
|
251 |
if (filterVal) {
|
252 |
table.setFilter(filterVal, typeVal, valueEl.value);
|
253 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
}
|
255 |
// Update filters on value change
|
256 |
document.getElementById("filter-field").addEventListener("change", updateFilter);
|
|
|
263 |
valueEl.value = "";
|
264 |
table.clearFilter();
|
265 |
});
|
266 |
+
// Handle button click for downloading JSON
|
267 |
+
document.getElementById("download-json").addEventListener("click", function() {
|
268 |
+
var tableData = table.getData(); // Получаем все данные таблицы
|
269 |
+
var jsonData = JSON.stringify(tableData, null, 2); // Преобразуем данные в JSON-строку
|
270 |
+
var blob = new Blob([jsonData], {type: "application/json"});
|
271 |
+
var url = URL.createObjectURL(blob);
|
272 |
+
var a = document.createElement("a");
|
273 |
+
a.href = url;
|
274 |
+
a.download = "data.json";
|
275 |
+
a.click();
|
276 |
+
URL.revokeObjectURL(url);
|
277 |
+
});
|
278 |
+
// Handle button click for downloading PDF
|
279 |
+
document.getElementById("download-pdf").addEventListener("click", function() {
|
280 |
+
table.download("pdf", "data.pdf", {
|
281 |
+
orientation:"portrait", //set page orientation to portrait
|
282 |
+
title:"Example Report" //add title to report
|
283 |
+
});
|
284 |
+
});
|
285 |
+
// Handle button click for downloading CSV
|
286 |
+
document.getElementById("download-csv").addEventListener("click", function() {
|
287 |
+
table.download("csv", "data.csv");
|
288 |
});
|
289 |
})
|
290 |
.catch(error => console.error('Error fetching data:', error));
|