From f8a551e694238ac8689543e353265ad657f7d80f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=AF=E4=B8=80?= Date: Mon, 28 Dec 2015 20:09:52 +0800 Subject: [PATCH 1/2] [refine] add spaced element for can't expand rows when data.i.children.length --- assets/index.less | 8 +++++++- src/Table.jsx | 2 ++ src/TableRow.jsx | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/assets/index.less b/assets/index.less index 577581ae5..b9333eef2 100644 --- a/assets/index.less +++ b/assets/index.less @@ -63,6 +63,12 @@ -webkit-user-select: none; user-select: none; } + &-spaced { + visibility: hidden; + } + &-spaced:after { + content: '.' + } &-expanded:after { content: '-' @@ -72,4 +78,4 @@ content: '+' } } -} \ No newline at end of file +} diff --git a/src/Table.jsx b/src/Table.jsx index 340d33041..cae8b0f91 100644 --- a/src/Table.jsx +++ b/src/Table.jsx @@ -147,6 +147,7 @@ const Table = React.createClass({ const keyFn = props.rowKey; const rowClassName = props.rowClassName; const expandedRowClassName = props.expandedRowClassName; + const needIndentSpaced = props.data.filter(a => (a[childrenColumnName] || []).length).length ? true : false; for (let i = 0; i < data.length; i++) { const record = data[i]; const key = keyFn ? keyFn(record, i) : undefined; @@ -160,6 +161,7 @@ const Table = React.createClass({ rst.push(); + } else if (i === 0 && needIndentSpaced) { + expandIcon = (); } if (expandIconAsCell && i === 0) { From a10f18e0722e0666b07d9b6fa92c0515fe456dfd Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 28 Dec 2015 21:31:28 +0800 Subject: [PATCH 2/2] filter => some --- src/Table.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Table.jsx b/src/Table.jsx index cae8b0f91..a73a212b7 100644 --- a/src/Table.jsx +++ b/src/Table.jsx @@ -147,7 +147,8 @@ const Table = React.createClass({ const keyFn = props.rowKey; const rowClassName = props.rowClassName; const expandedRowClassName = props.expandedRowClassName; - const needIndentSpaced = props.data.filter(a => (a[childrenColumnName] || []).length).length ? true : false; + const needIndentSpaced = props.data.some(record => + record[childrenColumnName] && record[childrenColumnName].length > 0); for (let i = 0; i < data.length; i++) { const record = data[i]; const key = keyFn ? keyFn(record, i) : undefined;