From fb66e9c7e32e6c54a0c435b561ada0da51253161 Mon Sep 17 00:00:00 2001 From: Liu Yang Date: Thu, 25 Aug 2016 21:12:23 +0800 Subject: [PATCH] apply sorter for children --- components/table/Table.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/table/Table.jsx b/components/table/Table.jsx index fdd7a35d5a..c143fc6455 100644 --- a/components/table/Table.jsx +++ b/components/table/Table.jsx @@ -719,12 +719,16 @@ export default class Table extends React.Component { getLocalData() { const state = this.state; - let data = this.props.dataSource || []; + const { dataSource, childrenColumnName } = this.props; + let data = dataSource || []; // 优化本地排序 data = data.slice(0); const sorterFn = this.getSorterFn(); if (sorterFn) { - data = data.sort(sorterFn); + data = data.sort(sorterFn).map(dataItem => (dataItem[childrenColumnName] ? { + ...dataItem, + [childrenColumnName]: dataItem[childrenColumnName].sort(sorterFn), + } : dataItem)); } // 筛选 if (state.filters) {