TableHeader中key值设定

This commit is contained in:
wanghaoo 2018-12-04 13:26:33 +08:00
parent 3bcbdcfa42
commit f967964d98
4 changed files with 32 additions and 35 deletions

View File

@ -592,7 +592,7 @@ var TableHeader = function (_Component) {
if (!da.fixed) { if (!da.fixed) {
return _react2["default"].createElement( return _react2["default"].createElement(
"th", "th",
{ key: Math.random() + new Date().getTime(), className: thClassName, "data-th-fixed": da.fixed, { key: da.dataindex, className: thClassName, "data-th-fixed": da.fixed,
"data-line-key": da.key, "data-line-index": columIndex, "data-th-width": da.width }, "data-line-key": da.key, "data-line-index": columIndex, "data-th-width": da.width },
da.children, da.children,
dragborder ? _react2["default"].createElement( dragborder ? _react2["default"].createElement(

View File

@ -72,35 +72,11 @@ function dragColumn(Table) {
columns[index] = dragSourceColum; columns[index] = dragSourceColum;
} }
} }
// let titles = [];
// columns.forEach(da=>{
// for(let attr of da){
// }
// if(typeof da.title != "string"){
// titles.push(da.title);
// delete da.title;
// }
// });
// let newColumns = null;
// if(titles.length != 0){
// newColumns = JSON.parse(JSON.stringify(columns));
// for (let index = 0; index < newColumns.length; index++) {
// newColumns[index].title = titles[index];
// }
// console.log("----columns----",newColumns);
// }else{
// newColumns = JSON.parse(JSON.stringify(columns));
// }
// this.setState({
// columns:newColumns
// });
_this.setState({ _this.setState({
columns: cloneDeep(columns) columns: cloneDeep(columns)
}); });
if (_this.props.dragDrop) { if (_this.props.onDrop) {
_this.props.dragDrop(event, data, newColumns); _this.props.onDrop(event, data, columns);
} }
}; };

View File

@ -143,21 +143,31 @@ function multiSelect(Table, Checkbox) {
if (checkedAll) { if (checkedAll) {
check = false; check = false;
} else { } else {
if (indeterminate) { // if(indeterminate){
// check = true;
// }else{
// check = true;
// }
check = true; check = true;
} else {
check = true;
}
} }
var selectList = []; var selectList = [];
data.forEach(function (item) { data.forEach(function (item) {
if (!item._disabled) {
item._checked = check; item._checked = check;
}
if (item._checked) { if (item._checked) {
selectList.push(item); selectList.push(item);
} }
}); });
if (selectList.length > 0) {
indeterminate = true;
} else {
indeterminate = false;
}
_this2.setState({ _this2.setState({
indeterminate: false, indeterminate: indeterminate,
checkedAll: check checkedAll: check
}); });
_this2.props.getSelectedDataFunc(selectList); _this2.props.getSelectedDataFunc(selectList);
@ -190,11 +200,22 @@ function multiSelect(Table, Checkbox) {
indeterminate = _state2.indeterminate; indeterminate = _state2.indeterminate;
var checkAttr = { checked: checkedAll ? true : false }; var checkAttr = { checked: checkedAll ? true : false };
var data = _this2.props.data;
var dataLength = data.length;
var disabledCount = 0;
indeterminate ? checkAttr.indeterminate = true : ""; indeterminate ? checkAttr.indeterminate = true : "";
//设置表头Checkbox是否可以点击
data.forEach(function (item, index, arr) {
if (item._disabled) {
disabledCount++;
}
});
var _defaultColumns = [{ var _defaultColumns = [{
title: _react2["default"].createElement(Checkbox, _extends({ title: _react2["default"].createElement(Checkbox, _extends({
className: 'table-checkbox' className: 'table-checkbox'
}, checkAttr, { }, checkAttr, {
disabled: disabledCount == dataLength ? true : false,
onChange: _this2.onAllCheckChange onChange: _this2.onAllCheckChange
})), })),
key: "checkbox", key: "checkbox",

View File

@ -536,7 +536,7 @@ class TableHeader extends Component {
} }
thClassName += `${fixedStyle}`; thClassName += `${fixedStyle}`;
if(!da.fixed){ if(!da.fixed){
return (<th key={Math.random()+new Date().getTime()} className={thClassName} data-th-fixed={da.fixed} return (<th key={da.dataindex} className={thClassName} data-th-fixed={da.fixed}
data-line-key={da.key} data-line-index={columIndex} data-th-width={da.width} > data-line-key={da.key} data-line-index={columIndex} data-th-width={da.width} >
{da.children} {da.children}
{ {