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

@atlaskit/dynamic-table

원문 보기 위키 갱신

내장된 페이징, 정렬, 재정렬 기능으로 데이터 행을 표시하는 다이내믹 테이블 컴포넌트예요.

출처: 문서

본문

Dynamic table 컴포넌트

다이내믹 테이블은 내장된 페이징, 정렬, 재정렬 기능으로 데이터 행을 표시해요.

  • Keywords: table, dynamic-table, data, sortable, rows, columns, sorting, pagination, drag and drop, ranking
  • Categories: data display
  • Status: general-availability

예시

import DynamicTable from '@atlaskit/dynamic-table';
import { head, rows } from './content/sample-data';
export default function TableUncontrolled(): React.JSX.Element {
	return (
		<DynamicTable
			head={head}
			rows={rows}
			rowsPerPage={5}
			defaultPage={1}
			loadingSpinnerSize="large"
			isRankable
			testId="table"
		/>
	);
}

예시

import React, { useState } from 'react';
import Banner from '@atlaskit/banner/banner';
import ButtonGroup from '@atlaskit/button/button-group';
import Button from '@atlaskit/button/default/button';
import { cssMap } from '@atlaskit/css';
import { DynamicTableStateless } from '@atlaskit/dynamic-table';
import WarningIcon from '@atlaskit/icon/core/status-warning';
import { Flex } from '@atlaskit/primitives/compiled/flex';
import { token } from '@atlaskit/tokens';
import { head, rows } from './content/sample-data';
const iconSpacingStyles = cssMap({
	space050: {
		paddingBlock: token('space.050'),
		paddingInline: token('space.050'),
	},
});
export default function TableControlled(): React.JSX.Element {
	const [pageNumber, setPageNumber] = useState(3);
	const navigateTo = (pageNumber: number) => {
		setPageNumber(pageNumber);
	};
	return (
		<>
			<Banner
				appearance="warning"
				icon={
					<Flex xcss={iconSpacingStyles.space050}>
						<WarningIcon label="" />
					</Flex>
				}
			>
				This is a stateless table example, which doesn't have pagination support. To navigate pages,
				use the "Previous page" and "Next page" buttons.
			</Banner>
			<ButtonGroup label="Paging navigation">
				<Button isDisabled={pageNumber === 1} onClick={() => navigateTo(pageNumber - 1)}>
					Previous Page
				</Button>
				<Button isDisabled={pageNumber === 5} onClick={() => navigateTo(pageNumber + 1)}>
					Next Page
				</Button>
			</ButtonGroup>
			<DynamicTableStateless
				head={head}
				rows={rows}
				rowsPerPage={5}
				page={pageNumber}
				loadingSpinnerSize="large"
				isLoading={false}
				isFixedSize
				sortKey="term"
				sortOrder="DESC"
				onSort={() => console.log('onSort')}
				onSetPage={() => console.log('onSetPage')}
			/>
		</>
	);
}

Props

Prop Type Description
caption string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal Caption for the table styled as a heading
defaultPage number When the table is initially rendered, use this to set which page number is shown by default
defaultSortKey string Sets which column the rows should be sorted by when the table is initially rendered
defaultSortOrder "ASC" | "DESC" Default column sort order used when initially rendering
emptyView ReactElement<any, string | JSXElementConstructor<any>> Shown when the table has no content
head HeadType Cells to be placed in the head of the table
highlightedRowIndex number | number[] Use this to set if the row will be highlighted
isFixedSize boolean Use this to force columns to use their initial width regardless of the size of the content that loads in
isLoading boolean Displays a loading spinner overlaid on top of the current page
isRankable boolean Use this to enable drag and drop sorting of table rows
isRankingDisabled boolean Disables being able to drop rows on the table
label string If you don’t use a caption, then you’ll need to use label to describe the table for assistive technologies
loadingLabel string Use this to set a label for assistive technology that describes the loading state
loadingSpinnerSize "small" | "large" Configuration of the loading spinner shown when isLoading is true
onPageRowsUpdate (pageRows: RowType[]) => void A callback that happens when the rows displayed on a page have changed
onRankEnd (rankEnd: RankEnd) => void A callback that happens when a drop of a row has completed
onRankStart (rankStart: RankStart) => void A callback that happens when a drag of a row has started
onSetPage (page: number, UIAnalyticsEvent?: UIAnalyticsEvent) => void A callback that happens when the table page has changed
onSort (data: any, UIAnalyticsEvent?: UIAnalyticsEvent) => void A callback that happens when a column heading has been sorted
page number Page the table should show
paginationi18n I18nShape Labels for the previous and next buttons used in pagination
rows RowType[] Rows to be placed in the table
rowsPerPage number Use this to control how many rows should be displayed per page
sortKey string Column key that the rows should be sorted by
sortOrder "ASC" | "DESC" Column sort order

DynamicTableStateless 컴포넌트

페이징, 정렬, 데이터를 외부에서 제어해야 할 때 사용하는 상태 비저장(stateless) 다이내믹 테이블이에요. 커스텀 상태 관리와 통합할 때 사용해요.

  • Keywords: table, dynamic-table, stateless, controlled, pagination, sorting
  • Categories: data display
  • Status: general-availability

예시

import React, { useState } from 'react';
import Banner from '@atlaskit/banner/banner';
import ButtonGroup from '@atlaskit/button/button-group';
import Button from '@atlaskit/button/default/button';
import { cssMap } from '@atlaskit/css';
import { DynamicTableStateless } from '@atlaskit/dynamic-table';
import WarningIcon from '@atlaskit/icon/core/status-warning';
import { Flex } from '@atlaskit/primitives/compiled/flex';
import { token } from '@atlaskit/tokens';
import { head, rows } from './content/sample-data';
const iconSpacingStyles = cssMap({
	space050: {
		paddingBlock: token('space.050'),
		paddingInline: token('space.050'),
	},
});
export default function TableControlled(): React.JSX.Element {
	const [pageNumber, setPageNumber] = useState(3);
	const navigateTo = (pageNumber: number) => {
		setPageNumber(pageNumber);
	};
	return (
		<>
			<Banner
				appearance="warning"
				icon={
					<Flex xcss={iconSpacingStyles.space050}>
						<WarningIcon label="" />
					</Flex>
				}
			>
				This is a stateless table example, which doesn't have pagination support. To navigate pages,
				use the "Previous page" and "Next page" buttons.
			</Banner>
			<ButtonGroup label="Paging navigation">
				<Button isDisabled={pageNumber === 1} onClick={() => navigateTo(pageNumber - 1)}>
					Previous Page
				</Button>
				<Button isDisabled={pageNumber === 5} onClick={() => navigateTo(pageNumber + 1)}>
					Next Page
				</Button>
			</ButtonGroup>
			<DynamicTableStateless
				head={head}
				rows={rows}
				rowsPerPage={5}
				page={pageNumber}
				loadingSpinnerSize="large"
				isLoading={false}
				isFixedSize
				sortKey="term"
				sortOrder="DESC"
				onSort={() => console.log('onSort')}
				onSetPage={() => console.log('onSetPage')}
			/>
		</>
	);
}

Props

Prop Type Description
caption string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal Caption for the table styled as a heading
emptyView React.ReactElement<any, string | React.JSXElementConstructor<any>> Shown when the table has no content
head HeadType Cells to be placed in the head of the table
highlightedRowIndex number | number[] Use this to set which rows will be highlighted
isFixedSize boolean Use this to force columns to use their initial width regardless of the size of the content that loads in
isLoading boolean Displays a loading spinner overlaid on top of the current page
isRankable boolean Use this to enable drag and drop sorting of table rows
isRankingDisabled boolean Disables being able to drop rows on the table
label string If you don’t use a caption, then you’ll need to use label to describe the table for assistive technologies
loadingLabel string Accessible name for loading states spinner
loadingSpinnerSize "small" | "large" Sets the size of the loading spinner when isLoading is true
onPageRowsUpdate (pageRows: RowType[]) => void A callback that happens when the rows displayed on a page have changed
onRankEnd (rankEnd: RankEnd, uiAnalyticsEvent?: UIAnalyticsEvent) => void A callback that happens when a drop of a row has completed
onRankStart (rankStart: RankStart) => void A callback that happens when a drag of a row has started
onSetPage (page: number, UIAnalyticsEvent?: UIAnalyticsEvent) => void A callback that happens when the table page has changed
onSort (data: any, UIAnalyticsEvent?: UIAnalyticsEvent) => void A callback that happens when a column heading has been sorted
page number Page the table should show
paginationi18n I18nShape Labels for the pagination wrapper, previous and next buttons used in pagination
rows RowType[] Rows to be placed in the table
rowsPerPage number Controls how many rows should be displayed per page
sortKey string Column key that the rows should be sorted by
sortOrder "ASC" | "DESC" Column sort order
totalRows number Total number of rows, in case of paginated data

사용 지침

  • 테이블 상태를 외부에서 제어해야 할 때 사용해요(예: 서버 측 페이징, 커스텀 정렬 로직).
  • 내장 페이징과 정렬로 충분하다면 DynamicTable(상태 저장)을 사용해요.

더 알아보기 (Learn more)