Skip to content

Commit 8c1941b

Browse files
committed
FA5 support
Fix of 0 Int problem changes to README
1 parent 49eda3f commit 8c1941b

File tree

6 files changed

+18
-11
lines changed

6 files changed

+18
-11
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ var ReactDatatable = require('@ashvin27/react-datatable')
226226
| key_column | string | id | Use to specify the key column name for each record
227227
| button | Object[] | { excel: false, print: false, csv: false } | Use to enable/disable export buttons(Excel, CSV, Print). By default buttons are disabled.
228228
| filename | String | "table" | Specify the export filename
229+
| fa5_support | Boolean | false | Enables support of Font Awesome 5 for icons
229230
| length_menu | Array[] | [10, 25, 50, 75, 100] | Specify the options in the page length `select` list.
230231
| page_size | Number | 10 | Specify the page length (number of rows per page)
231232
| sort | Object[] | { column: "", order: "asc" } | Initial sorting order to apply to the datatable

example/dist/index.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/components/TableHeader.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var _style2 = _interopRequireDefault(_style);
2020
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2121

2222
function TableHeader(props) {
23+
console.log(props);
2324
if (props.config.show_length_menu == true || props.config.show_filter == true || props.config.button.excel == true || props.config.button.csv == true || props.config.button.print == true) {
2425
return _react2.default.createElement(
2526
'div',
@@ -93,7 +94,7 @@ function TableHeader(props) {
9394
_react2.default.createElement(
9495
'span',
9596
null,
96-
_react2.default.createElement('i', { className: 'fa fa-file-excel-o', 'aria-hidden': 'true' })
97+
_react2.default.createElement('i', { className: props && props.config && props.config.fa5_support ? "fas fa-file-excel" : "fa fa-file-excel-o", 'aria-hidden': 'true' })
9798
)
9899
) : null,
99100
props.config.button.csv ? _react2.default.createElement(
@@ -107,7 +108,7 @@ function TableHeader(props) {
107108
_react2.default.createElement(
108109
'span',
109110
null,
110-
_react2.default.createElement('i', { className: 'fa fa-file-text-o', 'aria-hidden': 'true' })
111+
_react2.default.createElement('i', { className: props && props.config && props.config.fa5_support ? "fas fa-file-csv" : "fa fa-file-text-o", 'aria-hidden': 'true' })
111112
)
112113
) : null,
113114
props.config.button.print ? _react2.default.createElement(
@@ -121,7 +122,7 @@ function TableHeader(props) {
121122
_react2.default.createElement(
122123
'span',
123124
null,
124-
_react2.default.createElement('i', { className: 'glyphicon glyphicon-print fa fa-print', 'aria-hidden': 'true' })
125+
_react2.default.createElement('i', { className: "glyphicon glyphicon-print " + (props && props.config && props.config.fa5_support ? "fas fa-print" : "fa fa-print"), 'aria-hidden': 'true' })
125126
)
126127
) : null,
127128
props.config.button.extra == true ? props.extraButtons.map(function (elem, index) {

lib/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ var ReactDatatable = function (_Component) {
7474
extra: props.config && props.config.button && props.config.button.extra ? props.config.button.extra : false
7575
},
7676
filename: props.config && props.config.filename ? props.config.filename : "table",
77+
fa5_support: props.config && props.config.fa5_support ? props.config.fa5_support : false,
7778
key_column: props.config && props.config.key_column ? props.config.key_column : "id",
7879
language: {
7980
length_menu: props.config && props.config.language && props.config.language.length_menu ? props.config.language.length_menu : "Show _MENU_ records per page",
@@ -714,7 +715,7 @@ var ReactDatatable = function (_Component) {
714715
{ className: column.className, key: column.key ? column.key : column.text },
715716
column.cell(record, rowIndex)
716717
);
717-
} else if (record[column.key]) {
718+
} else if (record[column.key] !== undefined) {
718719
return _react2.default.createElement(
719720
'td',
720721
{ className: column.className, key: column.key ? column.key : column.text },
@@ -784,6 +785,7 @@ ReactDatatable.defaultProps = {
784785
csv: false
785786
},
786787
filename: "table",
788+
fa5_support: false,
787789
key_column: "id",
788790
language: {
789791
length_menu: "Show _MENU_ records per page",

src/components/TableHeader.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import includes from 'lodash/includes';
33
import style from '../style';
44

55
export default function TableHeader(props){
6+
console.log(props)
67
if(props.config.show_length_menu == true
78
|| props.config.show_filter == true
89
|| props.config.button.excel == true
@@ -54,7 +55,7 @@ export default function TableHeader(props){
5455
style={style.table_tool_btn}
5556
onClick={props.exportToExcel}>
5657
<span>
57-
<i className="fa fa-file-excel-o" aria-hidden="true"></i>
58+
<i className={(props&&props.config&&props.config.fa5_support)?"fas fa-file-excel":"fa fa-file-excel-o"} aria-hidden="true"></i>
5859
</span>
5960
</button>
6061
) : null}
@@ -66,7 +67,7 @@ export default function TableHeader(props){
6667
style={style.table_tool_btn}
6768
onClick={props.exportToCSV}>
6869
<span>
69-
<i className="fa fa-file-text-o" aria-hidden="true"></i>
70+
<i className={(props&&props.config&&props.config.fa5_support)?"fas fa-file-csv":"fa fa-file-text-o"} aria-hidden="true"></i>
7071
</span>
7172
</button>
7273
) : null}
@@ -78,7 +79,7 @@ export default function TableHeader(props){
7879
style={style.table_tool_btn}
7980
onClick={props.exportToPDF}>
8081
<span>
81-
<i className="glyphicon glyphicon-print fa fa-print" aria-hidden="true"></i>
82+
<i className={"glyphicon glyphicon-print "+((props&&props.config&&props.config.fa5_support)?"fas fa-print":"fa fa-print")} aria-hidden="true"></i>
8283
</span>
8384
</button>
8485
) : null}
@@ -108,4 +109,4 @@ export default function TableHeader(props){
108109
} else {
109110
return null;
110111
}
111-
}
112+
}

src/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class ReactDatatable extends Component {
3636
extra : (props.config && props.config.button && props.config.button.extra) ? props.config.button.extra : false,
3737
},
3838
filename: (props.config && props.config.filename) ? props.config.filename : "table",
39+
fa5_support: (props.config && props.config.fa5_support) ? props.config.fa5_support : false,
3940
key_column: props.config && props.config.key_column ? props.config.key_column : "id",
4041
language: {
4142
length_menu: (props.config && props.config.language && props.config.language.length_menu) ? props.config.language.length_menu : "Show _MENU_ records per page",
@@ -515,7 +516,7 @@ class ReactDatatable extends Component {
515516
this.props.columns.map((column, colIndex) => {
516517
if (column.cell && typeof column.cell === "function") {
517518
return (<td className={column.className} key={(column.key) ? column.key : column.text}>{column.cell(record,rowIndex)}</td>);
518-
}else if (record[column.key]) {
519+
}else if (record[column.key]!==undefined) {
519520
return (<td className={column.className} key={(column.key) ? column.key : column.text}>
520521
{record[column.key]}
521522
</td>);
@@ -581,6 +582,7 @@ ReactDatatable.defaultProps = {
581582
csv: false
582583
},
583584
filename: "table",
585+
fa5_support: false,
584586
key_column:"id",
585587
language: {
586588
length_menu: "Show _MENU_ records per page",

0 commit comments

Comments
 (0)