555555
This commit is contained in:
14
index.html
14
index.html
@@ -583,15 +583,8 @@ SELECT * FROM users LIMIT 10;"></textarea>
|
||||
const filterInputs = document.getElementById('filterInputs');
|
||||
const body = document.getElementById('tableBody');
|
||||
|
||||
if (records.length === 0) {
|
||||
headers.innerHTML = '';
|
||||
filterInputs.innerHTML = '';
|
||||
body.innerHTML = '<tr><td colspan="100%" class="text-center py-8 text-slate-500">Нет данных</td></tr>';
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate headers
|
||||
const columns = Object.keys(records[0]);
|
||||
const columns = records.length > 0 ? Object.keys(records[0]) : this.tableStructure.map(col => col.name);
|
||||
headers.innerHTML = columns.map(col => {
|
||||
const isSorted = this.sortColumn === col;
|
||||
const arrow = isSorted ? (this.sortDirection === 'ASC' ? '↑' : '↓') : '';
|
||||
@@ -603,7 +596,10 @@ SELECT * FROM users LIMIT 10;"></textarea>
|
||||
return `<td class="p-2"><input type="text" placeholder="Фильтр ${col}" class="w-full px-2 py-1 text-xs border border-slate-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500" oninput="app.updateFilter('${col}', this.value)" value="${this.filters[col] || ''}"></td>`;
|
||||
}).join('') + '<td class="p-2"><button onclick="app.clearFilters()" class="text-xs text-slate-500 hover:text-slate-700">Очистить</button></td>';
|
||||
|
||||
// Generate rows
|
||||
if (records.length === 0) {
|
||||
body.innerHTML = '<tr><td colspan="100%" class="text-center py-8 text-slate-500">Нет данных</td></tr>';
|
||||
return;
|
||||
}
|
||||
body.innerHTML = records.map(record => {
|
||||
const pkValue = this.primaryKey ? record[this.primaryKey] : null;
|
||||
const cells = columns.map(col => {
|
||||
|
||||
Reference in New Issue
Block a user