Skip to content

Commit

Permalink
New feature for text encoding added
Browse files Browse the repository at this point in the history
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 <jciccio@gmail.com>
  • Loading branch information
jciccio committed May 29, 2019
1 parent 08a0e14 commit 1ffc604
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

0 comments on commit 1ffc604

Please sign in to comment.