From 1ffc6040d85b7e7a40f18c368173f29ec81a11ad Mon Sep 17 00:00:00 2001 From: Jose Antonio Ciccio Date: Wed, 29 May 2019 17:01:59 -0600 Subject: [PATCH] New feature for text encoding added New feature for text encoding added * Added feature to specify the data encoding. Via `encoding` prop. By Default, the encoding is UTF-8 if prop is not passed. Otherwise it can be passed the data encoding wished for the text. Signed-off-by: Jose Antonio Ciccio --- README.md | 1 + package.json | 2 +- src/index.js | 7 +++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d7c8b9a..626b74d 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ Changes the background to white and the text to blue | ------------- |:-------------:| -----:|:-----| | content | object | Y |Contents to display on tables | | headers | array (String) | Y | Array of strings, these will be used to choose what to show in the table | +| encoding | String |N| Data encoding for table and file, UTF-8 by default | | minHeight | integer | Y| Min table desired height | | maxHeight | integer |Y | Max table desired height | | activateDownloadButton | boolean |Y | Activates download button | diff --git a/package.json b/package.json index 747537a..d32aee8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-js-table-with-csv-dl", - "version": "0.5.8", + "version": "0.6.0", "description": "React JS tables and log viewer with stats if needed. Has the functionality to dowload table contents in CSV file with data stored in class prop.", "main": "build/index.js", "peerDependencies": { diff --git a/src/index.js b/src/index.js index b243b91..d8da2f0 100644 --- a/src/index.js +++ b/src/index.js @@ -82,7 +82,9 @@ class TableViewer extends Component { } generateAndDownloadCSV() { - let csvType = {encoding:"UTF-8",type:"text/plain;charset=UTF-8"}; + + let encoding = this.props.encoding ? this.props.encoding : "UTF-8"; + let csvType = {encoding:encoding,type:"text/plain;charset="+encoding}; let filename = this.props.filename? this.props.filename : "logResults.csv"; var csvContent = ""; var data = this.props.content; @@ -429,7 +431,8 @@ TableViewer.propTypes = { activePageBoxStyle:PropTypes.object, maxPagesToDisplay: PropTypes.number, downloadButtonStyle:PropTypes.object, - sortColumn:PropTypes.string + sortColumn:PropTypes.string, + encoding:PropTypes.string }; export default TableViewer;