fix:解决树状表,不传 onExpandedRowsChange 属性,展不开节点的问题
This commit is contained in:
parent
9fa006ea36
commit
fcbe1c9c70
|
@ -112,7 +112,7 @@ function bigData(Table) {
|
||||||
_this.setStartAndEndIndex(currentIndex, dataLen);
|
_this.setStartAndEndIndex(currentIndex, dataLen);
|
||||||
}
|
}
|
||||||
if (newExpandedKeys !== props.expandedRowKeys) {
|
if (newExpandedKeys !== props.expandedRowKeys) {
|
||||||
_this.cacheExpandedKeys = newExpandedKeys;
|
_this.cacheExpandedKeys = new Set(newExpandedKeys);
|
||||||
//重新递归数据
|
//重新递归数据
|
||||||
var flatTreeData = _this.deepTraversal(data);
|
var flatTreeData = _this.deepTraversal(data);
|
||||||
var sliceTreeList = flatTreeData.slice(_this.startIndex, _this.endIndex);
|
var sliceTreeList = flatTreeData.slice(_this.startIndex, _this.endIndex);
|
||||||
|
@ -402,6 +402,7 @@ function bigData(Table) {
|
||||||
_this$expandedRowKeys = _this.expandedRowKeys,
|
_this$expandedRowKeys = _this.expandedRowKeys,
|
||||||
expandedRowKeys = _this$expandedRowKeys === undefined ? [] : _this$expandedRowKeys,
|
expandedRowKeys = _this$expandedRowKeys === undefined ? [] : _this$expandedRowKeys,
|
||||||
flatTreeKeysMap = _this.flatTreeKeysMap,
|
flatTreeKeysMap = _this.flatTreeKeysMap,
|
||||||
|
expandedKeysSet = cacheExpandedKeys ? cacheExpandedKeys : new Set(expandedRowKeys),
|
||||||
flatTreeData = [],
|
flatTreeData = [],
|
||||||
dataCopy = treeData;
|
dataCopy = treeData;
|
||||||
|
|
||||||
|
@ -410,11 +411,11 @@ function bigData(Table) {
|
||||||
var _dataCopy$i = dataCopy[i],
|
var _dataCopy$i = dataCopy[i],
|
||||||
key = _dataCopy$i.key,
|
key = _dataCopy$i.key,
|
||||||
children = _dataCopy$i.children,
|
children = _dataCopy$i.children,
|
||||||
props = _objectWithoutProperties(_dataCopy$i, ["key", "children"]);
|
props = _objectWithoutProperties(_dataCopy$i, ["key", "children"]),
|
||||||
|
dataCopyI = new Object(),
|
||||||
|
isLeaf = children ? false : true,
|
||||||
|
isExpanded = parentKey === null || expandedKeysSet.has(parentKey) ? expandedKeysSet.has(key) : false;
|
||||||
|
|
||||||
var dataCopyI = new Object();
|
|
||||||
var isLeaf = children ? false : true,
|
|
||||||
isExpanded = cacheExpandedKeys ? cacheExpandedKeys.indexOf(key) !== -1 : expandedRowKeys.indexOf(key) !== -1;
|
|
||||||
dataCopyI = _extends(dataCopyI, {
|
dataCopyI = _extends(dataCopyI, {
|
||||||
key: key,
|
key: key,
|
||||||
isExpanded: isExpanded,
|
isExpanded: isExpanded,
|
||||||
|
@ -642,20 +643,21 @@ function bigData(Table) {
|
||||||
_this4.setState({ needRender: !needRender });
|
_this4.setState({ needRender: !needRender });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_this4.treeType) {
|
|
||||||
//收起和展开时,缓存 expandedKeys
|
|
||||||
_this.cacheExpandedKeys = expandedRowKeys;
|
|
||||||
//重新递归数据
|
|
||||||
var flatTreeData = _this.deepTraversal(data);
|
|
||||||
var sliceTreeList = flatTreeData.slice(_this.startIndex, _this.endIndex);
|
|
||||||
_this.flatTreeData = flatTreeData;
|
|
||||||
_this.handleTreeListChange(sliceTreeList);
|
|
||||||
_this.cacheExpandedKeys = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// expandState为true时,记录下
|
// expandState为true时,记录下
|
||||||
_this.props.onExpand(expandState, record);
|
_this.props.onExpand(expandState, record);
|
||||||
|
|
||||||
|
if (_this4.treeType) {
|
||||||
|
//收起和展开时,缓存 expandedKeys
|
||||||
|
_this.cacheExpandedKeys = new Set(expandedRowKeys);
|
||||||
|
//重新递归数据
|
||||||
|
var flatTreeData = _this.deepTraversal(data);
|
||||||
|
var sliceTreeList = flatTreeData.slice(_this.startIndex, _this.endIndex);
|
||||||
|
_this.flatTreeData = flatTreeData;
|
||||||
|
_this.handleTreeListChange(sliceTreeList);
|
||||||
|
_this.cacheExpandedKeys = null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}, _temp;
|
}, _temp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -289702,7 +289702,7 @@
|
||||||
_this.setStartAndEndIndex(currentIndex, dataLen);
|
_this.setStartAndEndIndex(currentIndex, dataLen);
|
||||||
}
|
}
|
||||||
if (newExpandedKeys !== props.expandedRowKeys) {
|
if (newExpandedKeys !== props.expandedRowKeys) {
|
||||||
_this.cacheExpandedKeys = newExpandedKeys;
|
_this.cacheExpandedKeys = new Set(newExpandedKeys);
|
||||||
//重新递归数据
|
//重新递归数据
|
||||||
var flatTreeData = _this.deepTraversal(data);
|
var flatTreeData = _this.deepTraversal(data);
|
||||||
var sliceTreeList = flatTreeData.slice(_this.startIndex, _this.endIndex);
|
var sliceTreeList = flatTreeData.slice(_this.startIndex, _this.endIndex);
|
||||||
|
@ -289992,6 +289992,7 @@
|
||||||
_this$expandedRowKeys = _this.expandedRowKeys,
|
_this$expandedRowKeys = _this.expandedRowKeys,
|
||||||
expandedRowKeys = _this$expandedRowKeys === undefined ? [] : _this$expandedRowKeys,
|
expandedRowKeys = _this$expandedRowKeys === undefined ? [] : _this$expandedRowKeys,
|
||||||
flatTreeKeysMap = _this.flatTreeKeysMap,
|
flatTreeKeysMap = _this.flatTreeKeysMap,
|
||||||
|
expandedKeysSet = cacheExpandedKeys ? cacheExpandedKeys : new Set(expandedRowKeys),
|
||||||
flatTreeData = [],
|
flatTreeData = [],
|
||||||
dataCopy = treeData;
|
dataCopy = treeData;
|
||||||
|
|
||||||
|
@ -290000,11 +290001,11 @@
|
||||||
var _dataCopy$i = dataCopy[i],
|
var _dataCopy$i = dataCopy[i],
|
||||||
key = _dataCopy$i.key,
|
key = _dataCopy$i.key,
|
||||||
children = _dataCopy$i.children,
|
children = _dataCopy$i.children,
|
||||||
props = _objectWithoutProperties(_dataCopy$i, ["key", "children"]);
|
props = _objectWithoutProperties(_dataCopy$i, ["key", "children"]),
|
||||||
|
dataCopyI = new Object(),
|
||||||
|
isLeaf = children ? false : true,
|
||||||
|
isExpanded = parentKey === null || expandedKeysSet.has(parentKey) ? expandedKeysSet.has(key) : false;
|
||||||
|
|
||||||
var dataCopyI = new Object();
|
|
||||||
var isLeaf = children ? false : true,
|
|
||||||
isExpanded = cacheExpandedKeys ? cacheExpandedKeys.indexOf(key) !== -1 : expandedRowKeys.indexOf(key) !== -1;
|
|
||||||
dataCopyI = _extends(dataCopyI, {
|
dataCopyI = _extends(dataCopyI, {
|
||||||
key: key,
|
key: key,
|
||||||
isExpanded: isExpanded,
|
isExpanded: isExpanded,
|
||||||
|
@ -290232,20 +290233,21 @@
|
||||||
_this4.setState({ needRender: !needRender });
|
_this4.setState({ needRender: !needRender });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_this4.treeType) {
|
|
||||||
//收起和展开时,缓存 expandedKeys
|
|
||||||
_this.cacheExpandedKeys = expandedRowKeys;
|
|
||||||
//重新递归数据
|
|
||||||
var flatTreeData = _this.deepTraversal(data);
|
|
||||||
var sliceTreeList = flatTreeData.slice(_this.startIndex, _this.endIndex);
|
|
||||||
_this.flatTreeData = flatTreeData;
|
|
||||||
_this.handleTreeListChange(sliceTreeList);
|
|
||||||
_this.cacheExpandedKeys = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// expandState为true时,记录下
|
// expandState为true时,记录下
|
||||||
_this.props.onExpand(expandState, record);
|
_this.props.onExpand(expandState, record);
|
||||||
|
|
||||||
|
if (_this4.treeType) {
|
||||||
|
//收起和展开时,缓存 expandedKeys
|
||||||
|
_this.cacheExpandedKeys = new Set(expandedRowKeys);
|
||||||
|
//重新递归数据
|
||||||
|
var flatTreeData = _this.deepTraversal(data);
|
||||||
|
var sliceTreeList = flatTreeData.slice(_this.startIndex, _this.endIndex);
|
||||||
|
_this.flatTreeData = flatTreeData;
|
||||||
|
_this.handleTreeListChange(sliceTreeList);
|
||||||
|
_this.cacheExpandedKeys = null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}, _temp;
|
}, _temp;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -85,7 +85,7 @@ export default function bigData(Table) {
|
||||||
_this.setStartAndEndIndex(currentIndex,dataLen);
|
_this.setStartAndEndIndex(currentIndex,dataLen);
|
||||||
}
|
}
|
||||||
if(newExpandedKeys !== props.expandedRowKeys){
|
if(newExpandedKeys !== props.expandedRowKeys){
|
||||||
_this.cacheExpandedKeys = newExpandedKeys;
|
_this.cacheExpandedKeys = new Set(newExpandedKeys);
|
||||||
//重新递归数据
|
//重新递归数据
|
||||||
let flatTreeData = _this.deepTraversal(data);
|
let flatTreeData = _this.deepTraversal(data);
|
||||||
let sliceTreeList = flatTreeData.slice(_this.startIndex, _this.endIndex);
|
let sliceTreeList = flatTreeData.slice(_this.startIndex, _this.endIndex);
|
||||||
|
@ -130,14 +130,16 @@ export default function bigData(Table) {
|
||||||
deepTraversal = (treeData, parentKey=null, isShown) => {
|
deepTraversal = (treeData, parentKey=null, isShown) => {
|
||||||
const _this = this;
|
const _this = this;
|
||||||
let {cacheExpandedKeys, expandedRowKeys = [], flatTreeKeysMap} = _this,
|
let {cacheExpandedKeys, expandedRowKeys = [], flatTreeKeysMap} = _this,
|
||||||
|
expandedKeysSet = cacheExpandedKeys ? cacheExpandedKeys : new Set(expandedRowKeys),
|
||||||
flatTreeData = [],
|
flatTreeData = [],
|
||||||
dataCopy = treeData;
|
dataCopy = treeData;
|
||||||
if(Array.isArray(dataCopy)){
|
if(Array.isArray(dataCopy)){
|
||||||
for (let i=0, l=dataCopy.length; i<l; i++) {
|
for (let i=0, l=dataCopy.length; i<l; i++) {
|
||||||
let { key, children, ...props } = dataCopy[i];
|
let { key, children, ...props } = dataCopy[i],
|
||||||
let dataCopyI = new Object();
|
dataCopyI = new Object(),
|
||||||
let isLeaf = children ? false : true,
|
isLeaf = children ? false : true,
|
||||||
isExpanded = cacheExpandedKeys ? cacheExpandedKeys.indexOf(key) !== -1 : expandedRowKeys.indexOf(key) !== -1;
|
//如果父节点是收起状态,则子节点的展开状态无意义。(一级节点或根节点直接判断自身状态即可)
|
||||||
|
isExpanded = (parentKey === null || expandedKeysSet.has(parentKey)) ? expandedKeysSet.has(key) : false;
|
||||||
dataCopyI = Object.assign(dataCopyI,{
|
dataCopyI = Object.assign(dataCopyI,{
|
||||||
key,
|
key,
|
||||||
isExpanded,
|
isExpanded,
|
||||||
|
@ -517,20 +519,21 @@ export default function bigData(Table) {
|
||||||
this.setState({ needRender: !needRender });
|
this.setState({ needRender: !needRender });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.treeType) {
|
|
||||||
//收起和展开时,缓存 expandedKeys
|
|
||||||
_this.cacheExpandedKeys = expandedRowKeys;
|
|
||||||
//重新递归数据
|
|
||||||
let flatTreeData = _this.deepTraversal(data);
|
|
||||||
let sliceTreeList = flatTreeData.slice(_this.startIndex, _this.endIndex);
|
|
||||||
_this.flatTreeData = flatTreeData;
|
|
||||||
_this.handleTreeListChange(sliceTreeList);
|
|
||||||
_this.cacheExpandedKeys = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// expandState为true时,记录下
|
// expandState为true时,记录下
|
||||||
_this.props.onExpand(expandState, record);
|
_this.props.onExpand(expandState, record);
|
||||||
|
|
||||||
|
if(this.treeType) {
|
||||||
|
//收起和展开时,缓存 expandedKeys
|
||||||
|
_this.cacheExpandedKeys = new Set(expandedRowKeys);
|
||||||
|
//重新递归数据
|
||||||
|
let flatTreeData = _this.deepTraversal(data);
|
||||||
|
let sliceTreeList = flatTreeData.slice(_this.startIndex, _this.endIndex);
|
||||||
|
_this.flatTreeData = flatTreeData;
|
||||||
|
_this.handleTreeListChange(sliceTreeList);
|
||||||
|
_this.cacheExpandedKeys = null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue