본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Table

원문 보기 위키 갱신

데이터를 모으고, 보여 주고, 분석하고, 처리하는 데 쓰는 테이블(Table) 컴포넌트예요. 목록 형태의 데이터를 다룰 때 가장 기본이 되는 컴포넌트라고 볼 수 있어요.

출처: 문서

본문

API

Table

Property 설명 Type DefaultValue Version
borderCell 테이블 셀 테두리를 표시할지 여부예요. border={{ cell: true }}와 같아요 boolean - -
defaultExpandAllRows 펼칠 수 있는 모든 행을 기본으로 펼쳐요 boolean - -
hover hover 스타일을 켤지 여부예요 boolean true -
showHeader 헤더를 보여 줄지 여부예요 boolean true -
stripe 줄무늬(stripe) 스타일을 보여 줄지 여부예요 boolean - -
tableLayoutFixed 테이블의 table-layout 속성을 fixed로 설정해요. fixed로 설정하면 테이블 너비가 100%를 넘는 콘텐츠에 의해 늘어나지 않아요. boolean - -
virtualized 테이블이 가상 스크롤링을 켜서 대용량 데이터 시나리오를 처리해요.(주의: 가상 스크롤링은 트리 데이터 지원을 자동으로 꺼요) boolean - -
indentSize 트리 데이터의 각 단계마다 왼쪽으로 들여쓰는 픽셀 오프셋이에요 number 15 -
childrenColumnName data 안에서 트리 데이터의 필드 이름이에요. 기본값은 children이에요 string children -
onChange 페이지네이션, 정렬, 필터가 바뀔 때의 콜백이에요 (pagination: PaginationProps,sorter: SorterInfo | SorterInfo[],filters: Partial<Record<keyof T, string[]>>,extra: { currentData: T[]; currentAllData: T[]; action: 'paginate' | 'sort' | 'filter' }) => void - extra in 2.19.0, currentAllData in 2.53.0
pagePosition 페이지네이션의 위치를 정해요. 여섯 가지 위치 bottom right bottom left top right top left top center bottom center가 있어요 'br' | 'bl' | 'tr' | 'tl' | 'topCenter' | 'bottomCenter' br -
size 테이블 크기는 네 가지로 나뉘어요. default medium small mini 'default' | 'middle' | 'small' | 'mini' - -
noDataElement 데이터가 없을 때 보여 줄 요소예요 string | ReactNode <Empty /> -
placeholder 셀 내용이 비어 있을 때 플레이스홀더가 표시돼요. 우선순위는 column.placeholder보다 낮아요. ReactNode - 2.23.0
border 테두리를 설정해요 | boolean| { wrapper?: boolean; headerCell?: boolean; bodyCell?: boolean; cell?: boolean } true -
className 추가 css 클래스 string | string[] - -
columns 컬럼 객체의 배열이에요 ColumnProps<T>[] - -
components 네이티브 테이블 태그를 덮어 써요 ComponentsProps - -
data 표시할 데이터 레코드 배열이에요 T[] - -
defaultExpandedRowKeys 기본으로 펼쳐질 행을 정해요 (string | number)[] - -
expandedRowKeys 펼쳐진 행을 설정해요. (string | number)[] - -
expandProps 펼침 컬럼의 아이콘, 너비, 제목을 커스텀해요. 사용법은 [이 예시](/react/components/table#custom expand parameters)를 참고하세요 ExpandProps<T> - -
loading 테이블이 로딩 중인지 여부예요 boolean | SpinProps - -
onHeaderRow 헤더 행의 이벤트 콜백을 설정해요 (columns: ColumnProps<T>[], index: number) => RowCallbackProps - -
pagination 페이지네이션 설정이에요. Pagination 컴포넌트를 참고하고, false로 설정하면 페이지네이션이 숨어요 PaginationProps | boolean - -
rowSelection 테이블 행을 선택할 수 있는지, 선택 이벤트 등을 설정해요. 설정 항목 RowSelectionProps<T> - -
scroll x축 또는 y축의 스크롤을 설정해요. x를 true로 설정하면 테이블에 table-layout: fixed가, 부모 요소에는 overflow: auto가 추가돼요. y를 true로 설정하면 헤더와 바디가 분리되어 두 개의 테이블로 놓여요 { x?: number | string | boolean; y?: number | string | boolean } - -
showSorterTooltip 헤더에 다음 정렬을 알려 주는 툴팁을 보여 줄지 여부예요. 객체를 설정할 수 있고, Tooltip 컴포넌트의 모든 파라미터를 넘길 수 있어요. boolean | TooltipProps true 2.19.0
style 추가 스타일 CSSProperties - -
virtualListProps VirtualList를 설정하는 데 사용해요. AvailableVirtualListProps - 2.46.0
expandedRowRender 클릭하면 추가 행을 펼쳐서 렌더링하는 함수예요. 반환값이 null이면 펼침 버튼이 렌더링되지 않아요 (record: T, index: number) => ReactNode - -
footer 테이블의 푸터예요 (currentPageDate) => ReactNode - -
onExpand 펼치기 클릭 시 콜백이에요 (record: T, expanded: boolean) => void - -
onExpandedRowsChange 펼침 버튼이 클릭됐을 때의 콜백이에요. 파라미터는 펼쳐진 행들의 배열이에요 (expandedRows: (string | number)[]) => void - -
onRow 테이블 행의 이벤트 콜백을 설정해요 (record: T, index: number) => RowCallbackProps - -
renderPagination 페이지네이션 렌더링을 커스텀해요 (paginationNode?: ReactNode) => ReactNode - 2.11.0
rowClassName 테이블 행의 ClassName이에요 (record: T, index: number) => string - -
rowKey 테이블 행의 key예요 React.Key | ((record: T) => React.Key) key -
summary 테이블 요약이에요 (currentData?: T[]) => ReactNode - 2.17.0

RowSelection

rowSelection의 상세 파라미터예요.

Property 설명 Type DefaultValue Version
checkAll 전체 선택 버튼을 보여 줄지 여부예요 boolean - -
checkCrossPage 다중 선택 모드에서 체크박스가 페이지를 넘어 유지될지 여부예요. 비제어 모드에서만 동작하고, preserveSelectedRowKeys: true와 함께 쓰는 제어 모드에서도 동작해요. boolean - -
checkStrictly false로 설정하면 부모-자식 선택이 자동으로 연동돼요. boolean true 2.33.0
fixed 컬럼을 왼쪽에 고정할지 여부예요 boolean - -
preserveSelectedRowKeys 데이터 항목이 삭제돼도 key가 selectedRowKeys에 계속 유지돼요 boolean - 2.19.0
columnWidth 선택 컬럼의 너비예요 number - -
type 다중 선택 또는 단일 선택이에요 'checkbox' | 'radio' - -
columnTitle 선택 컬럼의 제목을 커스텀해요 string | ReactNode - -
selectedRowKeys 선택된 테이블 행이에요. (제어 모드, onChange와 함께 사용해야 해요) (string | number)[] - -
checkboxProps 선택 체크박스를 설정해요 (record: T) => { [key: string]: any } - -
onChange 체크박스/라디오가 바뀔 때의 콜백이에요 (selectedRowKeys: (string | number)[], selectedRows: T[]) => void - -
onSelect 사용자가 직접 선택/해제할 때의 콜백이에요 (selected: boolean, record: T, selectedRows: T[]) => void - 2.22.0
onSelectAll 사용자가 모든 행을 직접 선택/해제할 때의 콜백이에요 (selected: boolean, selectedRows) => void - 2.6.0
renderCell 체크박스를 커스텀해요. 사용법은 column.render와 같아요. (originNode, checked: boolean, record: T) => ReactNode - 2.19.0

ExpandProps

expandProps의 상세 파라미터예요.

Property 설명 Type DefaultValue Version
expandRowByClick 행을 클릭해서 펼치는 방식이에요 boolean - 2.19.0
strictTreeData 트리 데이터에서 children이 배열이고 길이가 1보다 클 때만 펼침 아이콘이 표시돼요. boolean true 2.27.0
width 펼침 아이콘 컬럼의 너비예요 number - -
columnTitle 펼침 아이콘 컬럼의 테이블 헤더 제목이에요 ReactNode - -
icon 펼침 버튼의 아이콘을 커스텀해요 (props: { expanded: boolean; record: Record<string, any> }) => ReactNode - -
rowExpandable 행 펼침을 허용할지 여부예요. 이 파라미터를 지정하지 않으면 expandedRowRender에 반환값이 있는지로 판단해요. 성능 문제가 생기면 rowExpandable 사용을 추천해요. (record: T) => boolean - 2.16.0

Column

컬럼은 데이터 객체를 설명하며, columns의 한 항목이에요.

Property 설명 Type DefaultValue Version
ellipsis 셀 내용이 길이를 넘으면 자동으로 생략되고 ...을 표시할지 여부예요. 이 속성을 설정하면 테이블의 table-layout이 자동으로 fixed가 돼요. boolean - -
filterMultiple 여러 항목을 필터링할 수 있는지 여부예요 boolean true -
dataIndex 데이터 항목에서 컬럼 데이터에 해당하는 key로, 값을 표시하는 데 사용돼요. a[0].bc[1] 같은 중첩 표기를 지원해요. [lodash.get](https:// www.npmjs.com/package/lodash.get)을 참고하세요. string - -
align 컬럼의 정렬을 설정해요 'left' | 'center' | 'right' left -
defaultSortOrder 기본 정렬 순서를 설정해요 'ascend' | 'descend' - -
fixed 헤더와 컬럼을 왼쪽 또는 오른쪽에 고정해요 'left' | 'right' - -
sortDirections 지원하는 정렬 방식이에요. Array<'ascend' | 'descend'> ['ascend','descend'] -
sortOrder 정렬 순서를 설정해요. 컬럼의 정렬을 제어할 수 있고, ascend descend로 설정할 수 있어요 'ascend' | 'descend' - -
filterIcon 커스텀 필터 아이콘이에요. ReactNode - -
placeholder 셀 내용이 비어 있을 때 플레이스홀더가 표시돼요. 우선순위는 render보다 낮아요. ReactNode - 2.22.0
title 컬럼 제목이에요 React.ReactNode (Required) - -
bodyCellStyle 테이블 바디 셀 스타일이에요 CSSProperties - -
className 컬럼의 ClassName이에요 string | string[] - -
defaultFilters 기본 필터를 설정해요 string[] - -
filterDropdownProps 필터 팝업 박스의 속성을 설정해요. { triggerProps?: TriggerProps } - -
filteredValue 필터 값을 설정해요. 값은 필터 값의 배열이에요 string[] - -
filters 필터 항목이에요. onFilter 또는 onChange와 함께 사용해야 해요 {text?: ReactNode;value?: any;[key: string]: any;}[] [] -
headerCellStyle 테이블 헤더 셀 스타일이에요 CSSProperties - -
key React key 값이에요. 지정하지 않으면 dataIndex의 기본값이 사용돼요 string | number - -
sorter 정렬 함수예요. 서버 사이드 정렬이나 추가 커스텀 동작을 원한다면 true로 설정하고 onChange 함수로 커스텀 정렬을 하세요 SorterFn | boolean | { compare?: SorterFn; multiple?: number } - -
width 컬럼 너비예요 number | string - -
filterDropdown 커스텀 필터 팝업 박스예요. (props: {filterKeys?: string[];setFilterKeys?: (filterKeys: string[], callback?: Function) => void;confirm?: Function;}) => ReactNode - -
onCell 테이블 바디 셀의 이벤트 콜백을 설정해요 (record, index) => RowCallbackProps - -
onFilter 필터가 바뀔 때의 콜백이에요 (value, row) => any - -
onFilterDropdownVisibleChange 필터 팝업의 표시 여부가 바뀔 때의 콜백이에요 (visible: boolean) => void - -
onHeaderCell 테이블 헤드 셀의 이벤트 콜백을 설정해요 (column, index) => RowCallbackProps - -
render 셀에 표시되는 내용을 커스텀해요 (col, item: T, index: number) => any - -

ComponentsProps

export type ComponentsProps = {
  table?: any;
  header?: {
    operations?: (nodes: {
      selectionNode?: ReactNode;
      expandNode?: ReactNode;
    }) => {
      name?: string;
      node?: ReactNode;
      width?: number;
    }[];
    wrapper?: any;
    thead?: any;
    row?: any;
    th?: any;
    cell?: any;
  };
  body?: {
    operations?: (nodes: {
      selectionNode?: ReactNode;
      expandNode?: ReactNode;
    }) => {
      name?: string;
      node?: ReactNode | ((record) => ReactNode); // 2.17.0
      width?: number;
    }[];
    wrapper?: any;
    tbody?: any;
    row?: any;
    td?: any;
    cell?: any;
  };
};

SorterInfo

export interface SorterInfo {
  direction?: SortDirection;
  field?: string | number;
  sorterFn?: SorterFn;
  priority?: number;
}

SortDirection

export declare type SortDirection = "descend" | "ascend";

SorterFn

export type SorterFn = (a: any, b: any) => number;

RowCallbackProps

export type RowCallbackProps = {
  onClick?: (event) => void;
  onDoubleClick?: (event) => void;
  onContextMenu?: (event) => void;
  onMouseEnter?: (event) => void;
  onMouseLeave?: (event) => void;
  onHandleSave?: (row) => void;
  [name: string]: any;
};

AvailableVirtualListProps

export type AvailableVirtualListProps = Pick<
  VirtualListProps<any>,
  | "height"
  | "itemHeight"
  | "threshold"
  | "isStaticItemHeight"
  | "scrollOptions"
  | "onScroll"
  | "wrapperChild"
>;

Hide Pagination

페이지 수가 한 페이지 이하일 때 페이지네이션을 숨기고 싶다면 pagination.hideOnSinglePage = true를 설정하면 돼요. 전역으로 설정하고 싶다면 ConfigProvider 컴포넌트의 tablePagination.hideOnSinglePage = true를 설정하면 돼요.

onRow

onRow, onHeaderRow, onCell, onHeaderCell은 사용법이 서로 같아요.

<Table
  onRow={(record, index) => {
    return {
      onClick: (event) => {}, // Click on the body row
      onDoubleClick: (event) => {},
      onContextMenu: (event) => {},
      onMouseEnter: (event) => {},
      onMouseLeave: (event) => {},
    };
  }}
  onHeaderRow={(column, index) => {
    return {
      onClick: (event) => {}, // Click on the head row
      onDoubleClick: (event) => {},
      onContextMenu: (event) => {},
      onMouseEnter: (event) => {},
      onMouseLeave: (event) => {},
    };
  }}
/>

더 알아보기 (Learn more)

Table 컴포넌트의 더 자세한 내용은 Arco Design 공식 문서(https://arco.design/themes/design/1/official/docs/en-US/components/table)에서 확인할 수 있어요.