From 021d033b066467528d3757629933628160c2a349 Mon Sep 17 00:00:00 2001 From: wanglinfang Date: Mon, 23 May 2022 14:32:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Table2=E4=BA=8B=E4=BB=B6=E5=8A=A8?= =?UTF-8?q?=E4=BD=9C=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/zh-CN/components/table-v2.md | 13 +- src/components/table/HeadCellFilter.tsx | 5 +- src/components/table/HeadCellSort.tsx | 2 +- src/components/table/index.tsx | 156 ++++++-------- .../Table-v2/HeadCellSearchDropdown.tsx | 23 ++- src/renderers/Table-v2/index.tsx | 192 ++++++++++++------ src/store/table-v2.ts | 111 +++++++++- 7 files changed, 328 insertions(+), 174 deletions(-) diff --git a/docs/zh-CN/components/table-v2.md b/docs/zh-CN/components/table-v2.md index b04faff1c..36eccf55e 100755 --- a/docs/zh-CN/components/table-v2.md +++ b/docs/zh-CN/components/table-v2.md @@ -191,7 +191,7 @@ order: 67 "rowSelection": { "type": "checkbox", "keyField": "id", - "selectedRowKeysExpr": "<%= data.record.id === 1 %>" + "selectedRowKeysExpr": "data.record.id === 1" }, "columns": [ { @@ -498,7 +498,7 @@ order: 67 "expandableOn": "this.record.id === 1 || this.record.id === 3", "keyField": "id", "expandedRowClassNameExpr": "<%= data.rowIndex % 2 ? 'bg-success' : '' %>", - "expandedRowKeysExpr": "<%= data.record.id == '3' %>" + "expandedRowKeysExpr": "data.record.id == '3'" }, "expandableBody": [ { @@ -809,10 +809,11 @@ order: 67 "type": "table-v2", "source": "$rows", "draggable": true, + "keyField": "id", "columns": [ { - "title": "Engine", - "key": "engine", + "title": "ID", + "key": "id" }, { "title": "Grade", @@ -827,8 +828,8 @@ order: 67 "key": "badgeText", "children": [ { - "title": "ID", - "key": "id" + "title": "Engine", + "key": "engine", } ] }, diff --git a/src/components/table/HeadCellFilter.tsx b/src/components/table/HeadCellFilter.tsx index 89b648c65..74e67679f 100644 --- a/src/components/table/HeadCellFilter.tsx +++ b/src/components/table/HeadCellFilter.tsx @@ -180,7 +180,10 @@ export class HeadCellFilter extends React.Component { const payload = {[column.key]: selectedKeys}; if (onFilter) { - const prevented = await onFilter(payload); + const prevented = await onFilter({ + filterName: column.key, + filterValue: selectedKeys?.join(',') + }); if (prevented) { return; } diff --git a/src/components/table/HeadCellSort.tsx b/src/components/table/HeadCellSort.tsx index 3a33e4a4f..11b4b1adc 100644 --- a/src/components/table/HeadCellSort.tsx +++ b/src/components/table/HeadCellSort.tsx @@ -51,7 +51,7 @@ export class HeadCellSort extends React.Component { } if (onSort) { - const prevented = onSort({ + const prevented = await onSort({ orderBy: this.state.orderBy, order: this.state.order }); diff --git a/src/components/table/index.tsx b/src/components/table/index.tsx index 4348f9970..3ddf8c70e 100644 --- a/src/components/table/index.tsx +++ b/src/components/table/index.tsx @@ -10,7 +10,6 @@ import find from 'lodash/find'; import isEqual from 'lodash/isEqual'; import filter from 'lodash/filter'; import intersection from 'lodash/intersection'; -import cloneDeep from 'lodash/cloneDeep'; import Sortable from 'sortablejs'; import {themeable, ClassNamesFn, ThemeProps} from '../../theme'; @@ -325,12 +324,15 @@ export class Table extends React.PureComponent { constructor(props: TableProps) { super(props); - this.selectedRows = props.rowSelection - ? this.getSelectedRows( - props.dataSource, - props.rowSelection?.selectedRowKeys - ) - : []; + if (props.rowSelection) { + const selectedResult = this.getSelectedRows( + props.dataSource, + props.rowSelection?.selectedRowKeys + ); + + this.selectedRows = selectedResult.selectedRows; + this.unSelectedRows = selectedResult.unSelectedRows; + } this.state = { selectedRowKeys: props.rowSelection @@ -361,6 +363,8 @@ export class Table extends React.PureComponent { tdColumns: Array; // 表格当前选中行 selectedRows: Array; + // 表格当前未选中行 + unSelectedRows: Array; // 拖拽排序 sortable: Sortable; // 记录点击起始横坐标 @@ -393,6 +397,7 @@ export class Table extends React.PureComponent { selectedRowKeys: Array ) { const selectedRows: Array = []; + const unSelectedRows: Array = []; dataSource.forEach(data => { if ( find( @@ -401,10 +406,12 @@ export class Table extends React.PureComponent { ) ) { selectedRows.push(data); + } else { + unSelectedRows.push(data); } }); - return selectedRows; + return {selectedRows, unSelectedRows}; } updateTableBodyFixed() { @@ -498,10 +505,12 @@ export class Table extends React.PureComponent { // 选择项发生了变化触发 if (!isEqual(prevState.selectedRowKeys, this.state.selectedRowKeys)) { // 更新保存的已选择行数据 - this.selectedRows = this.getSelectedRows( + const selectedResult = this.getSelectedRows( this.state.dataSource, this.state.selectedRowKeys ); + this.selectedRows = selectedResult.selectedRows; + this.unSelectedRows = selectedResult.unSelectedRows; const {rowSelection} = this.props; rowSelection && @@ -526,10 +535,12 @@ export class Table extends React.PureComponent { this.setState({ selectedRowKeys: this.props.rowSelection.selectedRowKeys }); - this.selectedRows = this.getSelectedRows( + const selectedResult = this.getSelectedRows( this.state.dataSource, this.state.selectedRowKeys ); + this.selectedRows = selectedResult.selectedRows; + this.unSelectedRows = selectedResult.unSelectedRows; } } @@ -599,37 +610,6 @@ export class Table extends React.PureComponent { this.destroyDragging(); } - exchange(fromIndex: number, toIndex: number, item: any) { - const {scroll, headSummary} = this.props; - // 如果有头部总结行 fromIndex就会+1 - if ((!scroll || (scroll && !scroll.y)) && headSummary) { - fromIndex = fromIndex - 1; - } - - const index = toIndex - fromIndex; - - const levels = item.getAttribute('row-levels'); - const rowIndex = +item.getAttribute('row-index'); - - const dataSource = cloneDeep(this.state.dataSource); - const levelsArray = levels ? levels.split(',') : []; - const childrenColumnName = this.getChildrenColumnName(); - let data: Array = dataSource; - let i = 0; - while (i < levelsArray.length) { - data = data[levelsArray[i]][childrenColumnName]; - i++; - } - - if (data && data.length > 0) { - const row = cloneDeep(data[rowIndex]); - data.splice(rowIndex, 1); - data.splice(rowIndex + index, 0, row); - } - - return data; - } - initDragging() { const {classnames: cx, onDrag} = this.props; @@ -666,14 +646,9 @@ export class Table extends React.PureComponent { return; } - const {onDrag} = this.props; - if (onDrag) { - const data = this.exchange(e.oldIndex, e.newIndex, e.item); - const prevented = await onDrag(data); - if (prevented) { - return; - } - } + const rowLevels = e.item.getAttribute('row-levels'); + + onDrag && onDrag(e.oldIndex, e.newIndex, rowLevels ? rowLevels.split(',') : []); } }); } @@ -1037,9 +1012,8 @@ export class Table extends React.PureComponent { const selectedRowKeys = value ? allRowKeys : []; if (onSelectAll) { const prevented = await onSelectAll( - value, - selectedRowKeys, selectedRows, + value ? [] : selectedRows, changeRows ); if (prevented) { @@ -1152,9 +1126,16 @@ export class Table extends React.PureComponent { ); } - onRowClick(event: React.ChangeEvent, record?: any, rowIndex?: number) { + async onRowClick(event: React.ChangeEvent, record?: any, rowIndex?: number) { const {rowSelection, onRow} = this.props; + if (onRow && onRow.onRowClick) { + const prevented = await onRow.onRowClick(event, record, rowIndex); + if (prevented) { + return; + } + } + if (rowSelection && rowSelection.type && rowSelection.rowClick) { const defaultKey = this.getRowSelectionKeyField(); @@ -1165,10 +1146,6 @@ export class Table extends React.PureComponent { this.selectedSingleRow(!isSelected, record); } - - if (record && onRow) { - onRow.onRowClick && onRow.onRowClick(event, record, rowIndex); - } } onRowMouseEnter( @@ -1350,42 +1327,41 @@ export class Table extends React.PureComponent { const defaultKey = this.getRowSelectionKeyField(); const isRadio = rowSelection && rowSelection.type === 'radio'; + let selectedRowKeys = []; + if (value) { + if (isRadio) { + selectedRowKeys = [data[defaultKey]]; + } else { + selectedRowKeys = [ + ...this.state.selectedRowKeys, + data[defaultKey], + ...this.getDataChildrenKeys(data) + ].filter((key, i, a) => a.indexOf(key) === i) + } + } else { + if (!isRadio) { + selectedRowKeys = this.state.selectedRowKeys.filter( + key => + ![data[defaultKey], ...this.getDataChildrenKeys(data)].includes( + key + ) + ) + } + } + if (onSelect) { + const selectedResult = this.getSelectedRows(this.state.dataSource, selectedRowKeys); const prevented = await onSelect( - data, - value, - this.selectedRows, - this.state.selectedRowKeys + selectedResult.selectedRows, + selectedRowKeys, + selectedResult.unSelectedRows ); if (prevented) { return; } } - if (value) { - if (isRadio) { - this.setState({selectedRowKeys: [data[defaultKey]]}); - } else { - this.setState(prevState => ({ - selectedRowKeys: [ - ...prevState.selectedRowKeys, - data[defaultKey], - ...this.getDataChildrenKeys(data) - ].filter((key, i, a) => a.indexOf(key) === i) - })); - } - } else { - if (!isRadio) { - this.setState({ - selectedRowKeys: this.state.selectedRowKeys.filter( - key => - ![data[defaultKey], ...this.getDataChildrenKeys(data)].includes( - key - ) - ) - }); - } - } + this.setState({selectedRowKeys}); } renderRow(data: any, rowIndex: number, levels: Array) { @@ -1396,6 +1372,7 @@ export class Table extends React.PureComponent { draggable, indentSize, rowClassName, + keyField, lineHeight // 是否设置了固定行高 } = this.props; @@ -1515,10 +1492,11 @@ export class Table extends React.PureComponent { key => key === data[defaultKey] ); const hasChildrenChecked = this.hasCheckedChildrenRows(data); + const isRadio = rowSelection && rowSelection.type === 'radio'; return [ { { if (!(rowSelection && rowSelection.rowClick)) { this.selectedSingleRow(value, data); @@ -1603,9 +1581,7 @@ export class Table extends React.PureComponent { ) : ( - this.state.dataSource.map((data, index) => { - return this.renderRow(data, index, []); - }) + this.state.dataSource.map((data, index) => this.renderRow(data, index, [])) )} ); diff --git a/src/renderers/Table-v2/HeadCellSearchDropdown.tsx b/src/renderers/Table-v2/HeadCellSearchDropdown.tsx index f9f7c1cc7..6ba957d22 100644 --- a/src/renderers/Table-v2/HeadCellSearchDropdown.tsx +++ b/src/renderers/Table-v2/HeadCellSearchDropdown.tsx @@ -143,8 +143,8 @@ export class HeadCellSearchDropDown extends React.Component< return schema || 'error'; } - handleAction(e: any, action: Action, ctx: object, confirm: Function) { - const {onAction} = this.props; + async handleAction(e: any, action: Action, ctx: object, confirm: Function) { + const {onAction, data, dispatchEvent, name} = this.props; if (action.actionType === 'cancel' || action.actionType === 'close') { confirm(); @@ -157,17 +157,14 @@ export class HeadCellSearchDropDown extends React.Component< return; } - onAction && onAction(e, action, ctx); - } - - async handleReset() { - const {onSearch, data, name, store, dispatchEvent} = this.props; const values = {...data}; + this.formItems.forEach(key => setVariable(values, key, undefined)); const rendererEvent = await dispatchEvent( 'columnSearch', createObject(data, { - ...values + searchName: name, + searchValue: values }) ); @@ -175,6 +172,13 @@ export class HeadCellSearchDropDown extends React.Component< return; } + onAction && onAction(e, action, ctx); + } + + async handleReset() { + const {onSearch, data, name, store} = this.props; + const values = {...data}; + this.formItems.forEach(key => setVariable(values, key, undefined)); if (values.orderBy === name) { @@ -200,7 +204,8 @@ export class HeadCellSearchDropDown extends React.Component< const rendererEvent = await dispatchEvent( 'columnSearch', createObject(data, { - ...values + searchName: name, + searchValue: values }) ); diff --git a/src/renderers/Table-v2/index.tsx b/src/renderers/Table-v2/index.tsx index 035152199..508acb4df 100644 --- a/src/renderers/Table-v2/index.tsx +++ b/src/renderers/Table-v2/index.tsx @@ -25,6 +25,7 @@ import {evalExpression, filter} from '../../utils/tpl'; import {isEffectiveApi} from '../../utils/api'; import Checkbox from '../../components/Checkbox'; import {BadgeSchema} from '../../components/Badge'; +import {Icon} from '../../components/icons'; import {TableStoreV2, ITableStore, IColumn, IRow} from '../../store/table-v2'; import {HeadCellSearchDropDown} from './HeadCellSearchDropdown'; @@ -383,10 +384,8 @@ export default class TableRenderer extends React.Component< onSelect && onSelect( - null, - false, - store.selectedRowKeys.map(item => item), - store.selectedRows.map(item => item.data) + store.selectedRows.map(item => item.data), + store.unSelectedRows.map(item => item.data) ); } @@ -431,11 +430,11 @@ export default class TableRenderer extends React.Component< // selectedRowKeysExpr比selectedRowKeys优先级高 if (props.rowSelection && props.rowSelection.selectedRowKeysExpr) { rows.forEach((row: any, index: number) => { - const flag = filter(props.rowSelection.selectedRowKeysExpr, { + const flag = evalExpression(props.rowSelection.selectedRowKeysExpr, { record: row, rowIndex: index }); - if (flag === 'true') { + if (flag) { selectedRowKeys.push(row[props?.rowSelection?.keyField || 'key']); } }); @@ -450,11 +449,11 @@ export default class TableRenderer extends React.Component< let expandedRowKeys: Array = []; if (props.expandable && props.expandable.expandedRowKeysExpr) { rows.forEach((row: any, index: number) => { - const flag = filter(props.expandable.expandedRowKeysExpr, { + const flag = evalExpression(props.expandable.expandedRowKeysExpr, { record: row, rowIndex: index }); - if (flag === 'true') { + if (flag) { expandedRowKeys.push(row[props?.expandable?.keyField || 'key']); } }); @@ -1019,19 +1018,16 @@ export default class TableRenderer extends React.Component< @autobind async handleSelected( - record: any, - value: boolean, selectedRows: Array, - selectedRowKeys: Array + selectedRowKeys: Array, + unSelectedRows: Array ) { const {dispatchEvent, data, rowSelection, onSelect, store} = this.props; const rendererEvent = await dispatchEvent( - 'selected', + 'selectedChange', createObject(data, { - record, - value, - selectedRows, - selectedRowKeys + selectedItems: selectedRows, + unSelectedItems: unSelectedRows }) ); @@ -1040,34 +1036,7 @@ export default class TableRenderer extends React.Component< } store.updateSelected(selectedRowKeys, rowSelection.keyField); - onSelect && onSelect(record, value, selectedRows, selectedRowKeys); - } - - @autobind - async handleSelectedAll( - value: boolean, - selectedRowKeys: Array, - selectedRows: Array, - changeRows: Array - ) { - const {dispatchEvent, data, rowSelection, onSelectAll, store} = this.props; - const rendererEvent = await dispatchEvent( - 'selectedAll', - createObject(data, { - value, - selectedRowKeys, - selectedRows, - changeRows - }) - ); - - if (rendererEvent?.prevented) { - return rendererEvent?.prevented; - } - - store.updateSelected(selectedRowKeys, rowSelection.keyField); - onSelectAll && - onSelectAll(value, selectedRowKeys, selectedRows, selectedRowKeys); + onSelect && onSelect(selectedRows, unSelectedRows); } @autobind @@ -1076,7 +1045,8 @@ export default class TableRenderer extends React.Component< const rendererEvent = await dispatchEvent( 'columnSort', createObject(data, { - ...payload + orderBy: payload.orderBy, + orderDir: payload.order }) ); @@ -1088,13 +1058,14 @@ export default class TableRenderer extends React.Component< } @autobind - async handleFilter(payload: any) { + async handleFilter(payload: { + filterName: string, + filterValue: string + }) { const {dispatchEvent, data, onFilter} = this.props; const rendererEvent = await dispatchEvent( 'columnFilter', - createObject(data, { - payload - }) + createObject(data, payload) ); if (rendererEvent?.prevented) { @@ -1105,24 +1076,66 @@ export default class TableRenderer extends React.Component< } @autobind - async handleDragOver(dataSource: Array) { - const {dispatchEvent, data, onDrag} = this.props; + async handleRowClick(event: React.ChangeEvent, rowItem: any, rowIndex?: number) { + const {dispatchEvent, data, onRow} = this.props; + const rendererEvent = await dispatchEvent( - 'dragOver', - createObject(data, { - dataSource - }) + 'rowClick', + createObject(data, {rowItem}) ); if (rendererEvent?.prevented) { return rendererEvent?.prevented; } - onDrag && onDrag(dataSource); + if (rowItem && onRow) { + onRow.onRowClick && onRow.onRowClick(event, rowItem, rowIndex); + } + } + + @autobind + async handleOrderChange(oldIndex: number, newIndex: number, levels: Array) { + const {store} = this.props; + const rowItem = store.getRowByIndex(oldIndex, levels); + + store.exchange(oldIndex, newIndex, rowItem); + } + + @autobind + async handleSaveOrder() { + const {store, onSaveOrder, data, dispatchEvent} = this.props; + + const movedItems = store.movedRows.map(item => item.data); + const items = store.rows.map(item => item.getDataWithModifiedChilden()); + + const rendererEvent = await dispatchEvent( + 'orderChange', + createObject(data, {movedItems}) + ); + + if (rendererEvent?.prevented) { + return; + } + + if (!onSaveOrder || !store.movedRows.length) { + return; + } + + onSaveOrder( + movedItems, + items + ); + } + + @autobind + reset() { + const {store} = this.props; + + store.reset(); } doAction(action: Action, args: any, throwErrors: boolean): any { - const {store, rowSelection} = this.props; + const {store, rowSelection, data} = this.props; const actionType = action?.actionType as string; const keyField = rowSelection?.keyField; @@ -1135,7 +1148,15 @@ export default class TableRenderer extends React.Component< store.updateSelected([], keyField); break; case 'select': - store.updateSelected(args?.selectedRowKeys, keyField); + const dataSource = store.getData(data); + const selected: Array = []; + dataSource.items.forEach((item: any, rowIndex: number) => { + const flag = evalExpression(args?.selectedRowKeysExpr, {record: item, rowIndex}); + if (flag) { + selected.push(item[keyField]); + } + }); + store.updateSelected(selected, keyField); break; default: break; @@ -1158,6 +1179,7 @@ export default class TableRenderer extends React.Component< placeholder, rowClassNameExpr, itemActions, + onRow, store, ...rest } = this.props; @@ -1310,23 +1332,73 @@ export default class TableRenderer extends React.Component< loading={this.renderSchema('loading', loading)} placeholder={this.renderSchema('placeholder', placeholder)} onSelect={this.handleSelected} - onSelectAll={this.handleSelectedAll} + onSelectAll={this.handleSelected} onSort={this.handleSort} onFilter={this.handleFilter} - onDrag={this.handleDragOver} + onDrag={this.handleOrderChange} itemActions={itemActionsConfig} + onRow={{ + ...onRow, + onRowClick: this.handleRowClick + }} > ); } + renderHeading() { + let { + store, + classnames: cx, + headingClassName, + translate: __ + } = this.props; + + if (store.moved) { + return ( +
+ { + store.moved ? ( + + {__('Table.moved', { + moved: store.moved + })} + + + + ) : null + } +
+ ); + } + + return null; + } + render() { const {classnames: cx} = this.props; this.renderedToolbars = []; // 用来记录哪些 toolbar 已经渲染了 + + const heading = this.renderHeading(); return (
{this.renderActions('header')} + {heading} {this.renderTable()}
); diff --git a/src/store/table-v2.ts b/src/store/table-v2.ts index 5faf8141f..bc17e4d10 100644 --- a/src/store/table-v2.ts +++ b/src/store/table-v2.ts @@ -23,7 +23,8 @@ import { isObject, immutableExtends, isEmpty, - extendObject + extendObject, + findTree } from '../utils/helper'; import {normalizeApiResponseData} from '../utils/api'; import {Api, Payload, fetchOptions, ApiObject} from '../types'; @@ -71,6 +72,7 @@ export const Row = types .model('Row', { storeType: 'Row', id: types.identifier, + parentId: '', key: types.string, pristine: types.frozen({} as any), // 原始数据 data: types.frozen({} as any), @@ -100,6 +102,10 @@ export const Row = types ); }, + get moved() { + return self.index !== self.newIndex; + }, + get locals(): any { let children: Array | null = null; if (self.children.length) { @@ -120,6 +126,20 @@ export const Row = types } : self.data ); + }, + + getDataWithModifiedChilden() { + let data = { + ...self.data + }; + + if (data.children && self.children) { + data.children = self.children.map(item => + item.getDataWithModifiedChilden() + ); + } + + return data; } })) .actions(self => ({ @@ -161,6 +181,10 @@ export const Row = types change(values: object, savePristine?: boolean) { self.data = immutableExtends(self.data, values); savePristine && (self.pristine = self.data); + }, + reset() { + self.newIndex = self.index; + self.data = self.pristine; } })); @@ -250,10 +274,26 @@ export const TableStoreV2 = ServiceStore.named('TableStoreV2') }); } + function getRowByIndex(rowIndex: number, levels?: Array): IRow { + if (levels && levels.length > 0) { + const index = +(levels.shift() || 0); + return getRowByIndex(index, levels); + } + return self.rows[rowIndex]; + } + function isSelected(row: IRow): boolean { return !!~self.selectedRows.indexOf(row); } + function getMovedRows() { + return flattenTree(self.rows).filter((item: IRow) => item.moved); + } + + function getMoved() { + return getMovedRows().length; + } + return { get toggable() { return getToggable(); @@ -287,6 +327,10 @@ export const TableStoreV2 = ServiceStore.named('TableStoreV2') return self.expandedRowKeys.map(item => item); }, + get unSelectedRows() { + return getUnSelectedRows(); + }, + // 是否隐藏了某列 hasColumnHidden() { return hasColumnHidden(); @@ -294,7 +338,21 @@ export const TableStoreV2 = ServiceStore.named('TableStoreV2') getData, - isSelected + getRowById(id: string) { + return findTree(self.rows, item => item.id === id); + }, + + isSelected, + + getRowByIndex, + + get moved() { + return getMoved(); + }, + + get movedRows() { + return getMovedRows(); + }, }; }) .actions(self => { @@ -333,6 +391,31 @@ export const TableStoreV2 = ServiceStore.named('TableStoreV2') } } + function exchange(fromIndex: number, toIndex: number, item?: IRow) { + item = item || self.rows[fromIndex]; + + if (item.parentId) { + const parent: IRow = self.getRowById(item.parentId) as any; + const offset = parent.children.indexOf(item) - fromIndex; + toIndex += offset; + fromIndex += offset; + + const newRows = parent.children.concat(); + newRows.splice(fromIndex, 1); + newRows.splice(toIndex, 0, item); + newRows.forEach((item, index) => (item.newIndex = index)); + parent.children.replace(newRows); + return; + } + + const newRows = self.rows.concat(); + newRows.splice(fromIndex, 1); + newRows.splice(toIndex, 0, item); + + newRows.forEach((item, index) => (item.newIndex = index)); + self.rows.replace(newRows); + } + function persistSaveToggledColumns() { const key = location.pathname + @@ -600,6 +683,22 @@ export const TableStoreV2 = ServiceStore.named('TableStoreV2') } }); + function reset() { + self.rows.forEach(item => item.reset()); + let rows = self.rows.concat(); + eachTree(rows, item => { + if (item.children) { + let rows = item.children.concat().sort((a, b) => a.index - b.index); + rows.forEach(item => item.reset()); + item.children.replace(rows); + } + }); + rows.forEach(item => item.reset()); + rows = rows.sort((a, b) => a.index - b.index); + self.rows.replace(rows); + self.dragging = false; + } + return { update, persistSaveToggledColumns, @@ -609,6 +708,8 @@ export const TableStoreV2 = ServiceStore.named('TableStoreV2') updateSelected, updateSelectedAll, updateExpanded, + exchange, + reset, // events afterCreate() { @@ -631,11 +732,7 @@ export const TableStoreV2 = ServiceStore.named('TableStoreV2') } }, 200); }, - saveRemote, - - getRowByIndex(rowIndex: number) { - return self.rows[rowIndex]; - } + saveRemote }; });