Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Table): add the expandIconIndex API to configure the display position of the expandIcon #3122

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/table/PrimaryTable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useRef, forwardRef, useImperativeHandle, ReactNode, RefAttributes } from 'react';
import get from 'lodash/get';
import classNames from 'classnames';
import isNumber from 'lodash/isNumber';
import BaseTable from './BaseTable';
import useColumnController from './hooks/useColumnController';
import useRowExpand from './hooks/useRowExpand';
Expand Down Expand Up @@ -28,7 +29,7 @@ export interface TPrimaryTableProps extends PrimaryTableProps, StyledProps {}

const PrimaryTable = forwardRef<PrimaryTableRef, TPrimaryTableProps>((originalProps, ref) => {
const props = useDefaultProps<TPrimaryTableProps>(originalProps, primaryTableDefaultProps);
const { columns, columnController, editableRowKeys, style, className } = props;
const { columns, columnController, editableRowKeys, style, className, expandIconIndex } = props;
const primaryTableRef = useRef(null);
const innerPagination = useRef<PaginationProps>(props.pagination);
const { classPrefix, tableDraggableClasses, tableBaseClass, tableSelectedClasses, tableSortClasses } = useClassName();
Expand Down Expand Up @@ -182,7 +183,12 @@ const PrimaryTable = forwardRef<PrimaryTableRef, TPrimaryTableProps>((originalPr
const tColumns = (() => {
const cols = getColumns(columns);
if (showExpandIconColumn) {
cols.unshift(getExpandColumn());
const iconColumns = getExpandColumn();
if (isNumber(expandIconIndex)) {
cols.splice(expandIconIndex, 0, iconColumns);
return cols;
}
cols.unshift(iconColumns);
}
return cols;
})();
Expand Down
4 changes: 4 additions & 0 deletions src/table/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,10 @@ export interface TdPrimaryTableProps<T extends TableRowData = TableRowData>
* @default true
*/
expandIcon?: boolean | TNode<ExpandArrowRenderParams<T>>;
/**
* 配置expandIcon的显示位置
*/
expandIconIndex?: number;
/**
* 是否允许点击行展开
*/
Expand Down
Loading