Fix issues table export.jquery.plugin deprecated #8070#8071
Fix issues table export.jquery.plugin deprecated #8070#8071marktech0813 wants to merge 4 commits into
Conversation
Updated CONTRIBUTING.md to reflect that Table Export is now built-in.
Updated docs in site/src/pages/docs/extensions/export.mdx: - Removed plugin requirement. - Documented built-in options (fileName, csvDelimiter, tableName) and supported types.
Implemented a built-in exporter in src/extensions/export/bootstrap-table-export.js that: - Supports types: json, xml, csv, txt, sql, and maps excel to CSV (.xls). - Preserves existing behaviors: fileName function support, footer export, column visibility (forceExport/forceHide), selected/all/basic export, and detail-view column exclusion via ignoreColumn. - Uses safe Blob download, avoiding deprecated/vulnerable plugin code. Contribution by Gittensor, learn more at https://gittensor.io/
|
Please check PR. |
|
That's awesome! |
…ixin#8071 Refactor CSV escaping and table matrix collection logic for improved readability and null handling. - Using strict equality checks for null/undefined. - Adding required blank lines between declarations and control statements. - Removing unnecessary arrow parens and extra parentheses. - Using template literals instead of string concatenation. - Ensuring single quotes and proper brace style. - Splitting multi-statements onto separate lines.
|
I fixed, Please check PR again, |
|
Nice! Any idea when/if it will be merge? |
|
Same question as @fsay2604 ! Any idea when this might be merged? I hit an issue with jQuery 4, where the the "trim" function has been removed. This function is used by tableexport.jquery.plugin - so the Export extension won't work with jQuery 4. |
|
+1 for review, this is a great change to not rely on external (and now deprecated) repos. Well done <3 |
|
Okay, I will review and conduct test verification as soon as possible. |
There was a problem hiding this comment.
Pull request overview
Replaces the deprecated tableExport.jquery.plugin dependency with a built-in export implementation in the export extension, and updates documentation/contribution guidance accordingly.
Changes:
- Implemented built-in export generation + Blob download for
json,xml,csv,txt,sql, and legacyexcel(mapped to CSV content with.xlsextension). - Updated export extension docs to remove the external plugin requirement and document built-in options/types.
- Updated CONTRIBUTING dependency list to reflect the built-in exporter.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/extensions/export/bootstrap-table-export.js | Replaces plugin-based export with built-in content builders and a Blob-based download flow. |
| site/src/pages/docs/extensions/export.mdx | Updates docs to describe built-in exporter options and supported types. |
| CONTRIBUTING.md | Updates dependency documentation for the export extension. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const csvEscape = (value, delimiter) => { | ||
| const d = delimiter || ',' | ||
|
|
||
| if (value === null || value === undefined) return '' | ||
|
|
||
| const str = String(value) | ||
| const mustQuote = str.includes(d) || str.includes('"') || str.includes('\n') || str.includes('\r') | ||
|
|
There was a problem hiding this comment.
The added helper code introduces trailing whitespace on blank lines (e.g., around this block). ESLint is configured with no-trailing-spaces: 'error' (eslint.config.js:85), so this will fail lint. Please remove the trailing spaces (or run the project formatter/linter autofix) in the new code.
| const lines = ['<?xml version="1.0" encoding="UTF-8"?>', `<${tableName}>`] | ||
|
|
There was a problem hiding this comment.
tableName is interpolated directly as the XML root element name. If exportOptions.tableName contains spaces or other invalid XML name characters, the generated XML becomes invalid. Please sanitize/normalize tableName to a safe XML element name (and fall back to a default when it cannot be made valid).
| r.forEach((v, i) => { | ||
| const key = headerRow[i] || `col${i + 1}` | ||
| lines.push(` <${key}>${esc(v)}</${key}>`) | ||
| }) |
There was a problem hiding this comment.
XML element names are derived from header text (key = headerRow[i]). Header labels commonly contain spaces/special characters, which produces invalid XML tags like <First Name>. Please normalize header-derived keys into valid XML element names (e.g., replace invalid characters, ensure a valid starting character) and fall back to colN when needed.
| const values = rows.map(r => `(${r.map(v => { | ||
| if (v === null || v === undefined || v === '') return 'NULL' | ||
| const s = String(v).replace(/'/g, '\'\'' ) | ||
| return `'${s}'` | ||
| }).join(', ')})`) | ||
|
|
||
| const sql = `INSERT INTO \`${tableName}\` (\`${cols.join('`, `')}\`) VALUES\n${values.join(',\n')};` |
There was a problem hiding this comment.
In the SQL export, tableName is used inside backticks without escaping backticks in the name, and when rows is empty the generated statement becomes VALUES\n; (invalid SQL). Please escape backticks in tableName similarly to column names, and handle the no-rows case by returning an empty string/file or a comment instead of an invalid INSERT.
| const values = rows.map(r => `(${r.map(v => { | |
| if (v === null || v === undefined || v === '') return 'NULL' | |
| const s = String(v).replace(/'/g, '\'\'' ) | |
| return `'${s}'` | |
| }).join(', ')})`) | |
| const sql = `INSERT INTO \`${tableName}\` (\`${cols.join('`, `')}\`) VALUES\n${values.join(',\n')};` | |
| // If there are no rows, avoid generating an invalid INSERT statement. | |
| if (!rows.length) { | |
| return { mime: 'application/sql;charset=utf-8', ext: 'sql', content: '' } | |
| } | |
| const values = rows.map(r => `(${r.map(v => { | |
| if (v === null || v === undefined || v === '') return 'NULL' | |
| const s = String(v).replace(/'/g, '\'\'' ) | |
| return `'${s}'` | |
| }).join(', ')})`) | |
| const safeTableName = String(tableName).replace(/`/g, '``') | |
| const sql = `INSERT INTO \`${safeTableName}\` (\`${cols.join('`, `')}\`) VALUES\n${values.join(',\n')};` |
| if (!built) { | ||
| // unsupported type without deprecated plugin; no-op but still restore state | ||
| onAfter() | ||
| return | ||
| } |
There was a problem hiding this comment.
When the export type is unsupported, doExport silently no-ops and restores state, but the caller still fires the export-saved event, which is misleading because no file was produced. Please have doExport return a success/failure flag (or throw/trigger an error event) so unsupported types can avoid emitting export-saved and optionally notify the user.
|
Hi @marktech0813, thanks for working on this! Replacing the deprecated plugin with a built-in exporter is a much-needed change. I've reviewed the PR in detail and have some feedback: Key Issues1. Data collection via DOM parsing instead of data API
I'd recommend collecting export data from bootstrap-table's internal data model ( 2. Export type reduction is a breaking changeThe plugin previously supported 10 types ( Would you consider keeping optional support for these types via lightweight libraries (e.g., SheetJS for xlsx, jsPDF for pdf)? 3.
|
What I changed
Supports types: json, xml, csv, txt, sql, and maps excel to CSV (.xls).
Preserves existing behaviors: fileName function support, footer export, column visibility (forceExport/forceHide), selected/all/basic export, and detail-view column exclusion via ignoreColumn.
Uses safe Blob download, avoiding deprecated/vulnerable plugin code.
Removed plugin requirement.
Documented built-in options (fileName, csvDelimiter, tableName) and supported types.
Notes
Status: I replaced the plugin with a built-in exporter, updated docs, and removed references.
I removed the deprecated tableExport.jquery.plugin usage and implemented a built‑in exporter.
Contribution by Gittensor, learn more at https://gittensor.io/