Skip to content

Commit

Permalink
chore: only accept CSV files
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding authored Jan 13, 2025
1 parent 933ebaa commit 8dac2fe
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions bootstrap5-i18n-demo/src/examples/slickgrid/Example43.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ export default function Example43() {
}

function handleFileImport(event: any) {
const file = event.target.files[0];
if (file) {
const file: File = event.target.files[0];
if (file.name.endsWith('.csv')) {
const reader = new FileReader();
reader.onload = (e: any) => {
const content = e.target.result;
dynamicallyCreateGrid(content);
};
reader.readAsText(file);
} else {
alert('File must be a CSV file');
}
}

Expand Down Expand Up @@ -135,7 +137,8 @@ export default function Example43() {
<button id="uploadBtn" data-test="static-data-btn" className="btn btn-outline-secondary" onClick={() => handleDefaultCsv()}>
Use default CSV data
</button>
<button className="btn btn-outline-danger ms-1" onClick={() => destroyGrid()}>Destroy Grid</button>
&nbsp;/
<button className="btn btn-outline-danger btn-sm ms-2" onClick={() => destroyGrid()}>Destroy Grid</button>
</div>
</div>

Expand Down

0 comments on commit 8dac2fe

Please sign in to comment.