Skip to content

Commit

Permalink
FA5 support
Browse files Browse the repository at this point in the history
Fix of 0 Int problem
changes to README
  • Loading branch information
mkikets99 committed Feb 9, 2021
1 parent 49eda3f commit 8c1941b
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ var ReactDatatable = require('@ashvin27/react-datatable')
| key_column | string | id | Use to specify the key column name for each record
| button | Object[] | { excel: false, print: false, csv: false } | Use to enable/disable export buttons(Excel, CSV, Print). By default buttons are disabled.
| filename | String | "table" | Specify the export filename
| fa5_support | Boolean | false | Enables support of Font Awesome 5 for icons
| length_menu | Array[] | [10, 25, 50, 75, 100] | Specify the options in the page length `select` list.
| page_size | Number | 10 | Specify the page length (number of rows per page)
| sort | Object[] | { column: "", order: "asc" } | Initial sorting order to apply to the datatable
Expand Down
4 changes: 2 additions & 2 deletions example/dist/index.js

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions lib/components/TableHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var _style2 = _interopRequireDefault(_style);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function TableHeader(props) {
console.log(props);
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) {
return _react2.default.createElement(
'div',
Expand Down Expand Up @@ -93,7 +94,7 @@ function TableHeader(props) {
_react2.default.createElement(
'span',
null,
_react2.default.createElement('i', { className: 'fa fa-file-excel-o', 'aria-hidden': 'true' })
_react2.default.createElement('i', { className: props && props.config && props.config.fa5_support ? "fas fa-file-excel" : "fa fa-file-excel-o", 'aria-hidden': 'true' })
)
) : null,
props.config.button.csv ? _react2.default.createElement(
Expand All @@ -107,7 +108,7 @@ function TableHeader(props) {
_react2.default.createElement(
'span',
null,
_react2.default.createElement('i', { className: 'fa fa-file-text-o', 'aria-hidden': 'true' })
_react2.default.createElement('i', { className: props && props.config && props.config.fa5_support ? "fas fa-file-csv" : "fa fa-file-text-o", 'aria-hidden': 'true' })
)
) : null,
props.config.button.print ? _react2.default.createElement(
Expand All @@ -121,7 +122,7 @@ function TableHeader(props) {
_react2.default.createElement(
'span',
null,
_react2.default.createElement('i', { className: 'glyphicon glyphicon-print fa fa-print', 'aria-hidden': 'true' })
_react2.default.createElement('i', { className: "glyphicon glyphicon-print " + (props && props.config && props.config.fa5_support ? "fas fa-print" : "fa fa-print"), 'aria-hidden': 'true' })
)
) : null,
props.config.button.extra == true ? props.extraButtons.map(function (elem, index) {
Expand Down
4 changes: 3 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ var ReactDatatable = function (_Component) {
extra: props.config && props.config.button && props.config.button.extra ? props.config.button.extra : false
},
filename: props.config && props.config.filename ? props.config.filename : "table",
fa5_support: props.config && props.config.fa5_support ? props.config.fa5_support : false,
key_column: props.config && props.config.key_column ? props.config.key_column : "id",
language: {
length_menu: props.config && props.config.language && props.config.language.length_menu ? props.config.language.length_menu : "Show _MENU_ records per page",
Expand Down Expand Up @@ -714,7 +715,7 @@ var ReactDatatable = function (_Component) {
{ className: column.className, key: column.key ? column.key : column.text },
column.cell(record, rowIndex)
);
} else if (record[column.key]) {
} else if (record[column.key] !== undefined) {
return _react2.default.createElement(
'td',
{ className: column.className, key: column.key ? column.key : column.text },
Expand Down Expand Up @@ -784,6 +785,7 @@ ReactDatatable.defaultProps = {
csv: false
},
filename: "table",
fa5_support: false,
key_column: "id",
language: {
length_menu: "Show _MENU_ records per page",
Expand Down
9 changes: 5 additions & 4 deletions src/components/TableHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import includes from 'lodash/includes';
import style from '../style';

export default function TableHeader(props){
console.log(props)
if(props.config.show_length_menu == true
|| props.config.show_filter == true
|| props.config.button.excel == true
Expand Down Expand Up @@ -54,7 +55,7 @@ export default function TableHeader(props){
style={style.table_tool_btn}
onClick={props.exportToExcel}>
<span>
<i className="fa fa-file-excel-o" aria-hidden="true"></i>
<i className={(props&&props.config&&props.config.fa5_support)?"fas fa-file-excel":"fa fa-file-excel-o"} aria-hidden="true"></i>
</span>
</button>
) : null}
Expand All @@ -66,7 +67,7 @@ export default function TableHeader(props){
style={style.table_tool_btn}
onClick={props.exportToCSV}>
<span>
<i className="fa fa-file-text-o" aria-hidden="true"></i>
<i className={(props&&props.config&&props.config.fa5_support)?"fas fa-file-csv":"fa fa-file-text-o"} aria-hidden="true"></i>
</span>
</button>
) : null}
Expand All @@ -78,7 +79,7 @@ export default function TableHeader(props){
style={style.table_tool_btn}
onClick={props.exportToPDF}>
<span>
<i className="glyphicon glyphicon-print fa fa-print" aria-hidden="true"></i>
<i className={"glyphicon glyphicon-print "+((props&&props.config&&props.config.fa5_support)?"fas fa-print":"fa fa-print")} aria-hidden="true"></i>
</span>
</button>
) : null}
Expand Down Expand Up @@ -108,4 +109,4 @@ export default function TableHeader(props){
} else {
return null;
}
}
}
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ReactDatatable extends Component {
extra : (props.config && props.config.button && props.config.button.extra) ? props.config.button.extra : false,
},
filename: (props.config && props.config.filename) ? props.config.filename : "table",
fa5_support: (props.config && props.config.fa5_support) ? props.config.fa5_support : false,
key_column: props.config && props.config.key_column ? props.config.key_column : "id",
language: {
length_menu: (props.config && props.config.language && props.config.language.length_menu) ? props.config.language.length_menu : "Show _MENU_ records per page",
Expand Down Expand Up @@ -515,7 +516,7 @@ class ReactDatatable extends Component {
this.props.columns.map((column, colIndex) => {
if (column.cell && typeof column.cell === "function") {
return (<td className={column.className} key={(column.key) ? column.key : column.text}>{column.cell(record,rowIndex)}</td>);
}else if (record[column.key]) {
}else if (record[column.key]!==undefined) {
return (<td className={column.className} key={(column.key) ? column.key : column.text}>
{record[column.key]}
</td>);
Expand Down Expand Up @@ -581,6 +582,7 @@ ReactDatatable.defaultProps = {
csv: false
},
filename: "table",
fa5_support: false,
key_column:"id",
language: {
length_menu: "Show _MENU_ records per page",
Expand Down

0 comments on commit 8c1941b

Please sign in to comment.