Skip to content

Commit bd14b22

Browse files
committed
expose key field name of each record #37
1 parent 8816342 commit bd14b22

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

example/dist/index.js

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

example/src/UserList.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Component, Fragment } from 'react';
2-
// import ReactDatatable from '../../lib/index.js';
3-
import ReactDatatable from '../../src/index.js';
2+
import ReactDatatable from '../../lib/index.js';
3+
// import ReactDatatable from '../../src/index.js';
44

55
class UserList extends Component {
66
constructor(props) {

lib/ADPagination.js

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ function ADPagination(props) {
3333

3434
var Add = function Add(s, f) {
3535
var _loop = function _loop(i) {
36-
console.log('i', i);
3736
tags.push(_react2.default.createElement(
3837
Item,
3938
{

lib/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
4848
* This is the React Component for ReactDatatable
4949
*
5050
* @package ReactDatatable
51-
* @author Ashvin Patel
51+
* @author Ashvin Patel([email protected])
5252
* @date 14 Dec, 2018
5353
*/
5454

@@ -115,6 +115,7 @@ var ReactDatatable = function (_Component) {
115115
extra: props.config && props.config.button && props.config.button.extra ? props.config.button.extra : false
116116
},
117117
filename: props.config && props.config.filename ? props.config.filename : "table",
118+
key_column: props.config && props.config.key_column ? props.config.key_column : "id",
118119
language: {
119120
length_menu: props.config && props.config.language && props.config.language.length_menu ? props.config.language.length_menu : "Show _MENU_ records per page",
120121
filter: props.config && props.config.language && props.config.language.filter ? props.config.language.filter : "Search in records...",
@@ -695,7 +696,7 @@ var ReactDatatable = function (_Component) {
695696
rowIndex = _lodash2.default.indexOf(_this8.props.records, record);
696697
return _react2.default.createElement(
697698
'tr',
698-
{ key: record.id, onClick: function onClick(e) {
699+
{ key: record[_this8.config.key_column], onClick: function onClick(e) {
699700
return _this8.props.onRowClicked(e, record, rowIndex);
700701
} },
701702
_this8.props.columns.map(function (column, colIndex) {
@@ -953,6 +954,7 @@ ReactDatatable.defaultProps = {
953954
csv: false
954955
},
955956
filename: "table",
957+
key_column: "id",
956958
language: {
957959
length_menu: "Show _MENU_ records per page",
958960
filter: "Search in records...",

0 commit comments

Comments
 (0)