Skip to content

Commit

Permalink
ver. 9.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
光弘 committed Aug 10, 2018
1 parent ac98f47 commit 4fc0693
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uxcore-table",
"version": "9.4.2",
"version": "9.4.3",
"description": "table ui component for react",
"repository": "https://github.com/uxcore/uxcore-table.git",
"author": "zhouquan.yezq",
Expand Down
8 changes: 4 additions & 4 deletions src/Row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Row extends React.Component {

['rowIndex', 'index', 'mode', 'renderModel', 'fixedColumn',
'levels', 'addRowClassName', 'renderSubComp', 'visible',
'checkboxColumnKey', 'locale', 'isHover', 'isTreeLoading'].forEach((item) => {
'checkboxColumnKey', 'locale', 'isHover', 'treeLoadingIds'].forEach((item) => {
if (me.props[item] !== nextProps[item]) {
shouldUpdate = true;
}
Expand Down Expand Up @@ -159,7 +159,7 @@ class Row extends React.Component {
return children;
}

renderExpandIcon(rowIndex) {
renderExpandIcon(rowIndex, treeId) {
let expandCollapseIcon;
let _expandIconClass;
const props = this.props;
Expand All @@ -168,7 +168,7 @@ class Row extends React.Component {
return false;
}

if (props.isTreeLoading) {
if (props.treeLoadingIds.indexOf(treeId) > -1) {
expandCollapseIcon = (
<span
className="kuma-uxtable-expand-icon"
Expand Down Expand Up @@ -339,7 +339,7 @@ class Row extends React.Component {
return (
<Cell {...renderProps}>
{me.renderIndent()}
{me.renderExpandIcon(props.rowIndex)}
{me.renderExpandIcon(props.rowIndex, props.rowData.__treeId__)}
{me.renderTreeRowSelector()}
</Cell>
);
Expand Down
3 changes: 2 additions & 1 deletion src/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Table extends React.Component {
searchTxt: '',
expandedKeys: [],
filterColumns: {},
treeLoadingIds: [],
};
this.handleBodyScroll = this.handleBodyScroll.bind(this);
this.handleHeaderScroll = this.handleHeaderScroll.bind(this);
Expand Down Expand Up @@ -1245,7 +1246,7 @@ class Table extends React.Component {
expandedKeys: state.expandedKeys,
currentHoverRow: state.currentHoverRow,
rowGroupActiveKey: state.rowGroupActiveKey,
isTreeLoading: state.isTreeLoading,
treeLoadingIds: state.treeLoadingIds,
data,
bodyHeight,
hasFooter: this.hasFooter(),
Expand Down
2 changes: 1 addition & 1 deletion src/Tbody.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class Tbody extends React.Component {
handleDataChange: props.handleDataChange,
attachCellField: props.attachCellField,
detachCellField: props.detachCellField,
isTreeLoading: props.isTreeLoading,
treeLoadingIds: props.treeLoadingIds,
visible: true,
bodyNode: this.root,
};
Expand Down
13 changes: 7 additions & 6 deletions src/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,18 +244,19 @@ function getData(validate) {
function changeTreeExpandState({ tableData, rowData }, cb = () => {}) {
const expandedKeys = deepcopy(this.state.expandedKeys);
util.toggleItemInArr(rowData.jsxid, expandedKeys);
const filteredTreeLoadingIds = this.state.treeLoadingIds.filter(id => id !== rowData.__treeId__);
if (tableData) {
this.data = tableData;
this.setState({
isTreeLoading: false,
treeLoadingIds: filteredTreeLoadingIds,
expandedKeys,
data: tableData,
}, () => {
cb();
});
} else {
this.setState({
isTreeLoading: false,
treeLoadingIds: filteredTreeLoadingIds,
expandedKeys,
}, () => {
cb();
Expand All @@ -264,13 +265,13 @@ function changeTreeExpandState({ tableData, rowData }, cb = () => {}) {
}

function toggleTreeExpanded(rowData, cb) {
if (this.state.isTreeLoading) {
return;
}
const { loadTreeData } = this.props;
const { treeLoadingIds } = this.state;
if (Array.isArray(rowData.data) && !rowData.data.length && loadTreeData) {
const newTreeLoadingIds = [...treeLoadingIds];
newTreeLoadingIds.push(rowData.__treeId__);
this.setState({
isTreeLoading: true,
treeLoadingIds: newTreeLoadingIds,
});
const loadedResult = loadTreeData(rowData);
const loadedAction = (content) => {
Expand Down

0 comments on commit 4fc0693

Please sign in to comment.