feat: 增加columnKey属性,column[columnKey]可作为主键
This commit is contained in:
parent
816b84733e
commit
1b49ce5d4d
|
@ -84,6 +84,8 @@ var propTypes = {
|
|||
//特殊的渲染规则的key值
|
||||
rowKey: _propTypes2["default"].oneOfType([_propTypes2["default"].string, _propTypes2["default"].func]),
|
||||
rowClassName: _propTypes2["default"].func,
|
||||
//column的主键,和 column.key 作用相同
|
||||
columnKey: _propTypes2["default"].string,
|
||||
expandedRowClassName: _propTypes2["default"].func,
|
||||
childrenColumnName: _propTypes2["default"].string,
|
||||
onExpand: _propTypes2["default"].func,
|
||||
|
@ -127,6 +129,7 @@ var defaultProps = {
|
|||
expandIconAsCell: false,
|
||||
defaultExpandAllRows: false,
|
||||
defaultExpandedRowKeys: [],
|
||||
columnKey: 'key',
|
||||
rowKey: 'key',
|
||||
rowClassName: function rowClassName() {
|
||||
return '';
|
||||
|
@ -668,6 +671,7 @@ var Table = function (_Component) {
|
|||
|
||||
var currentRow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||
var rows = arguments[2];
|
||||
var columnKey = this.props.columnKey;
|
||||
var _state = this.state,
|
||||
_state$contentWidthDi = _state.contentWidthDiff,
|
||||
contentWidthDiff = _state$contentWidthDi === undefined ? 0 : _state$contentWidthDi,
|
||||
|
@ -679,6 +683,9 @@ var Table = function (_Component) {
|
|||
rows[currentRow] = rows[currentRow] || [];
|
||||
|
||||
columns.forEach(function (column, i) {
|
||||
if (!column.key) {
|
||||
column.key = column[columnKey];
|
||||
}
|
||||
if (column.rowSpan && rows.length < column.rowSpan) {
|
||||
while (rows.length < column.rowSpan) {
|
||||
rows.push([]);
|
||||
|
|
|
@ -37121,6 +37121,8 @@
|
|||
//特殊的渲染规则的key值
|
||||
rowKey: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].func]),
|
||||
rowClassName: _propTypes2['default'].func,
|
||||
//column的主键,和 column.key 作用相同
|
||||
columnKey: _propTypes2['default'].string,
|
||||
expandedRowClassName: _propTypes2['default'].func,
|
||||
childrenColumnName: _propTypes2['default'].string,
|
||||
onExpand: _propTypes2['default'].func,
|
||||
|
@ -37164,6 +37166,7 @@
|
|||
expandIconAsCell: false,
|
||||
defaultExpandAllRows: false,
|
||||
defaultExpandedRowKeys: [],
|
||||
columnKey: 'key',
|
||||
rowKey: 'key',
|
||||
rowClassName: function rowClassName() {
|
||||
return '';
|
||||
|
@ -37705,6 +37708,7 @@
|
|||
|
||||
var currentRow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||
var rows = arguments[2];
|
||||
var columnKey = this.props.columnKey;
|
||||
var _state = this.state,
|
||||
_state$contentWidthDi = _state.contentWidthDiff,
|
||||
contentWidthDiff = _state$contentWidthDi === undefined ? 0 : _state$contentWidthDi,
|
||||
|
@ -37716,6 +37720,9 @@
|
|||
rows[currentRow] = rows[currentRow] || [];
|
||||
|
||||
columns.forEach(function (column, i) {
|
||||
if (!column.key) {
|
||||
column.key = column[columnKey];
|
||||
}
|
||||
if (column.rowSpan && rows.length < column.rowSpan) {
|
||||
while (rows.length < column.rowSpan) {
|
||||
rows.push([]);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -28,6 +28,8 @@ const propTypes = {
|
|||
//特殊的渲染规则的key值
|
||||
rowKey: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
||||
rowClassName: PropTypes.func,
|
||||
//column的主键,和 column.key 作用相同
|
||||
columnKey: PropTypes.string,
|
||||
expandedRowClassName: PropTypes.func,
|
||||
childrenColumnName: PropTypes.string,
|
||||
onExpand: PropTypes.func,
|
||||
|
@ -71,6 +73,7 @@ const defaultProps = {
|
|||
expandIconAsCell: false,
|
||||
defaultExpandAllRows: false,
|
||||
defaultExpandedRowKeys: [],
|
||||
columnKey: 'key',
|
||||
rowKey: 'key',
|
||||
rowClassName: () => '',
|
||||
expandedRowClassName: () => '',
|
||||
|
@ -482,12 +485,16 @@ class Table extends Component {
|
|||
}
|
||||
|
||||
getHeaderRows(columns, currentRow = 0, rows) {
|
||||
const { columnKey } = this.props;
|
||||
let { contentWidthDiff = 0, lastShowIndex = -1 } = this.state;
|
||||
let filterCol = [];
|
||||
rows = rows || [];
|
||||
rows[currentRow] = rows[currentRow] || [];
|
||||
|
||||
columns.forEach((column,i) => {
|
||||
if (!column.key) {
|
||||
column.key = column[columnKey];
|
||||
}
|
||||
if (column.rowSpan && rows.length < column.rowSpan) {
|
||||
while (rows.length < column.rowSpan) {
|
||||
rows.push([]);
|
||||
|
|
Loading…
Reference in New Issue