Mercurial > packages > framework
comparison publishable/resources/js/ServerTable.js @ 7:e6132a1e8e24 default tip
Adding better support for test among other base changes.
| author | Luka Sitas <sitas.luka.97@gmail.com> |
|---|---|
| date | Thu, 25 Sep 2025 19:58:32 -0400 |
| parents | 6ded573b0a61 |
| children |
comparison
equal
deleted
inserted
replaced
| 6:6ded573b0a61 | 7:e6132a1e8e24 |
|---|---|
| 6 * @param {Array} options.columns - Array of column configs: [{name, label, ...}] | 6 * @param {Array} options.columns - Array of column configs: [{name, label, ...}] |
| 7 * @param {number} [options.pageSize=10] - Default rows per page | 7 * @param {number} [options.pageSize=10] - Default rows per page |
| 8 * @param {Array} [options.initialSort=[]] - Default sort: [{col, dir}] | 8 * @param {Array} [options.initialSort=[]] - Default sort: [{col, dir}] |
| 9 * @param {Object} [options.headers={}] - Additional headers for requests | 9 * @param {Object} [options.headers={}] - Additional headers for requests |
| 10 * @param {string} [options.groupBy={}] - Which column to group by | 10 * @param {string} [options.groupBy={}] - Which column to group by |
| 11 * @param {Function} [options.postRender={}] - Function to call after rendering | |
| 11 * @param {Function} [options.groupRender={}] - Function to render the grouping | 12 * @param {Function} [options.groupRender={}] - Function to render the grouping |
| 12 */ | 13 */ |
| 13 constructor(rootEl, options) { | 14 constructor(rootEl, options) { |
| 14 this.rootEl = rootEl; | 15 this.rootEl = rootEl; |
| 15 this.endpoint = options.endpoint; | 16 this.endpoint = options.endpoint; |
| 18 this.sort = options.initialSort || []; | 19 this.sort = options.initialSort || []; |
| 19 this.filters = options.filters || {}; | 20 this.filters = options.filters || {}; |
| 20 this.currentPage = 1; | 21 this.currentPage = 1; |
| 21 this.headers = options.headers || {}; | 22 this.headers = options.headers || {}; |
| 22 this.groupBy = options.groupBy; | 23 this.groupBy = options.groupBy; |
| 24 this.postRender = options.postRender || null ; | |
| 23 this.groupRender = | 25 this.groupRender = |
| 24 options.groupRender || | 26 options.groupRender || |
| 25 ((g, rows) => | 27 ((g, rows) => |
| 26 `<tr class="st-group-row"><td colspan="${this.columns.length}">Group: ${g}</td></tr>`); | 28 `<tr class="st-group-row"><td colspan="${this.columns.length}">Group: ${g}</td></tr>`); |
| 27 | 29 |
| 199 ) | 201 ) |
| 200 .join("")}</tr>`, | 202 .join("")}</tr>`, |
| 201 ) | 203 ) |
| 202 .join(""); | 204 .join(""); |
| 203 } | 205 } |
| 204 } | 206 if(typeof this.postRender === "function") this.postRender(); |
| 207 } | |
| 208 | |
| 205 renderError() { | 209 renderError() { |
| 206 this.tbody.innerHTML = `<tr><td colspan="${this.columns.length}" style="color:red">${this.state.error}</td></tr>`; | 210 this.tbody.innerHTML = `<tr><td colspan="${this.columns.length}" style="color:red">${this.state.error}</td></tr>`; |
| 207 } | 211 } |
| 208 | 212 |
| 209 updateControls() { | 213 updateControls() { |
