diff --git a/public/js/table.js b/public/js/table.js index a99a33d..d3d1cc1 100644 --- a/public/js/table.js +++ b/public/js/table.js @@ -243,32 +243,8 @@ async function selectTable(schema, tableName, restoreState = false) { // Формируем колонки const columns = [ { - formatter: function(cell, formatterParams, onRendered) { - const row = cell.getRow(); - const checkbox = document.createElement("input"); - checkbox.type = "checkbox"; - checkbox.checked = row.isSelected(); - checkbox.style.cursor = "pointer"; - checkbox.style.width = "16px"; - checkbox.style.height = "16px"; - return checkbox; - }, - titleFormatter: function(cell, formatterParams, onRendered) { - const checkbox = document.createElement("input"); - checkbox.type = "checkbox"; - checkbox.style.cursor = "pointer"; - checkbox.style.width = "16px"; - checkbox.style.height = "16px"; - checkbox.addEventListener("click", function(e) { - e.stopPropagation(); - if (checkbox.checked) { - table.getRows().forEach(row => row.select()); - } else { - table.deselectRow(); - } - }); - return checkbox; - }, + formatter: "rowSelection", + titleFormatter: "rowSelection", hozAlign: "center", headerHozAlign: "center", headerSort: false, @@ -279,15 +255,7 @@ async function selectTable(schema, tableName, restoreState = false) { frozen: true, cellClick: function(e, cell) { e.stopPropagation(); - const row = cell.getRow(); - const checkbox = cell.getElement().querySelector('input[type="checkbox"]'); - if (row.isSelected()) { - row.deselect(); - if (checkbox) checkbox.checked = false; - } else { - row.select(); - if (checkbox) checkbox.checked = true; - } + cell.getRow().toggleSelect(); } }, ...currentMeta.columns.map(col => {