React Tree Grid Toolbar
Ignite UI for React Toolbar는 React 트리 그리드의 UI 작업을 위한 컨테이너입니다. React 도구 모음은 React 구성 요소의 맨 위에 있습니다. IgrTreeGrid
그리고 가로 크기와 일치합니다. 도구 모음 컨테이너는 사용자 지정 콘텐츠 또는 미리 정의된 UI 컨트롤 집합을 호스팅할 수 있습니다. React 트리 그리드의 기본 설정은 다음과 같습니다.
- 열 숨기기
- 열 고정
- 엑셀 내보내기
- 고급 필터링
툴바와 미리 정의된 UI 구성 요소는 React 이벤트를 지원하고 개발자에게 API를 제공합니다.
React 툴바 그리드 예제
export class EmployeesFlatAvatarsItem {
public constructor(init: Partial<EmployeesFlatAvatarsItem>) {
Object.assign(this, init);
}
public Age: number;
public Avatar: string;
public HireDate: string;
public ID: number;
public Name: string;
public ParentID: number;
public Title: string;
}
export class EmployeesFlatAvatars extends Array<EmployeesFlatAvatarsItem> {
public constructor(items: Array<EmployeesFlatAvatarsItem> | number = -1) {
if (Array.isArray(items)) {
super(...items);
} else {
const newItems = [
new EmployeesFlatAvatarsItem({ Age: 55, Avatar: `https://static.infragistics.com/xplatform/images/people/men/5.jpg`, HireDate: `2008-03-20`, ID: 1, Name: `Johnathan Winchester`, ParentID: -1, Title: `Development Manager` }),
new EmployeesFlatAvatarsItem({ Age: 42, Avatar: `https://static.infragistics.com/xplatform/images/people/women/4.jpg`, HireDate: `2014-01-22`, ID: 4, Name: `Ana Sanders`, ParentID: -1, Title: `CEO` }),
new EmployeesFlatAvatarsItem({ Age: 49, Avatar: `https://static.infragistics.com/xplatform/images/people/women/2.jpg`, HireDate: `2014-01-22`, ID: 18, Name: `Victoria Lincoln`, ParentID: -1, Title: `Accounting Manager` }),
new EmployeesFlatAvatarsItem({ Age: 61, Avatar: `https://static.infragistics.com/xplatform/images/people/men/4.jpg`, HireDate: `2010-01-01`, ID: 10, Name: `Yang Wang`, ParentID: -1, Title: `Localization Manager` }),
new EmployeesFlatAvatarsItem({ Age: 43, Avatar: `https://static.infragistics.com/xplatform/images/people/men/1.jpg`, HireDate: `2011-06-03`, ID: 3, Name: `Michael Burke`, ParentID: 1, Title: `Senior Software Developer` }),
new EmployeesFlatAvatarsItem({ Age: 29, Avatar: `https://static.infragistics.com/xplatform/images/people/men/2.jpg`, HireDate: `2009-06-19`, ID: 2, Name: `Thomas Anderson`, ParentID: 1, Title: `Senior Software Developer` }),
new EmployeesFlatAvatarsItem({ Age: 31, Avatar: `https://static.infragistics.com/xplatform/images/people/women/3.jpg`, HireDate: `2014-08-18`, ID: 11, Name: `Monica Reyes`, ParentID: 1, Title: `Software Development Team Lead` }),
new EmployeesFlatAvatarsItem({ Age: 35, Avatar: `https://static.infragistics.com/xplatform/images/people/men/3.jpg`, HireDate: `2015-09-17`, ID: 6, Name: `Roland Mendel`, ParentID: 11, Title: `Senior Software Developer` }),
new EmployeesFlatAvatarsItem({ Age: 44, Avatar: `https://static.infragistics.com/xplatform/images/people/men/6.jpg`, HireDate: `2009-10-11`, ID: 12, Name: `Sven Cooper`, ParentID: 11, Title: `Senior Software Developer` }),
new EmployeesFlatAvatarsItem({ Age: 44, Avatar: `https://static.infragistics.com/xplatform/images/people/men/7.jpg`, HireDate: `2014-04-04`, ID: 14, Name: `Laurence Johnson`, ParentID: 4, Title: `Director` }),
new EmployeesFlatAvatarsItem({ Age: 25, Avatar: `https://static.infragistics.com/xplatform/images/people/women/1.jpg`, HireDate: `2017-11-09`, ID: 5, Name: `Elizabeth Richards`, ParentID: 4, Title: `Vice President` }),
new EmployeesFlatAvatarsItem({ Age: 39, Avatar: `https://static.infragistics.com/xplatform/images/people/men/8.jpg`, HireDate: `2010-03-22`, ID: 13, Name: `Trevor Ashworth`, ParentID: 5, Title: `Director` }),
new EmployeesFlatAvatarsItem({ Age: 44, Avatar: `https://static.infragistics.com/xplatform/images/people/men/9.jpg`, HireDate: `2014-04-04`, ID: 17, Name: `Antonio Moreno`, ParentID: 18, Title: `Senior Accountant` }),
new EmployeesFlatAvatarsItem({ Age: 50, Avatar: `https://static.infragistics.com/xplatform/images/people/men/10.jpg`, HireDate: `2007-11-18`, ID: 7, Name: `Pedro Rodriguez`, ParentID: 10, Title: `Senior Localization Developer` }),
new EmployeesFlatAvatarsItem({ Age: 27, Avatar: `https://static.infragistics.com/xplatform/images/people/women/5.jpg`, HireDate: `2016-02-19`, ID: 8, Name: `Casey Harper`, ParentID: 10, Title: `Senior Localization Developer` }),
new EmployeesFlatAvatarsItem({ Age: 25, Avatar: `https://static.infragistics.com/xplatform/images/people/women/6.jpg`, HireDate: `2017-11-09`, ID: 15, Name: `Patricia Simpson`, ParentID: 7, Title: `Localization Intern` }),
new EmployeesFlatAvatarsItem({ Age: 39, Avatar: `https://static.infragistics.com/xplatform/images/people/men/26.jpg`, HireDate: `2010-03-22`, ID: 9, Name: `Francisco Chang`, ParentID: 7, Title: `Localization Intern` }),
new EmployeesFlatAvatarsItem({ Age: 25, Avatar: `https://static.infragistics.com/xplatform/images/people/men/27.jpg`, HireDate: `2018-03-18`, ID: 16, Name: `Peter Lewis`, ParentID: 7, Title: `Localization Intern` }),
];
super(...newItems.slice(0));
}
}
}
tsimport React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrTreeGridModule } from "@infragistics/igniteui-react-grids";
import { IgrAvatarModule } from "@infragistics/igniteui-react";
import { IgrTreeGrid, IgrGridToolbar, IgrGridToolbarActions, IgrGridToolbarAdvancedFiltering, IgrGridToolbarHiding, IgrGridToolbarPinning, IgrGridToolbarExporter, IgrColumn } from "@infragistics/igniteui-react-grids";
import { EmployeesFlatAvatarsItem, EmployeesFlatAvatars } from './EmployeesFlatAvatars';
import { IgrAvatar } from "@infragistics/igniteui-react";
import { IgrCellTemplateContext } from "@infragistics/igniteui-react-grids";
import "@infragistics/igniteui-react-grids/grids/themes/light/bootstrap.css";
const mods: any[] = [
IgrTreeGridModule,
IgrAvatarModule
];
mods.forEach((m) => m.register());
export default class Sample extends React.Component<any, any> {
private treeGrid: IgrTreeGrid
private treeGridRef(r: IgrTreeGrid) {
this.treeGrid = r;
this.setState({});
}
constructor(props: any) {
super(props);
this.treeGridRef = this.treeGridRef.bind(this);
}
public render(): JSX.Element {
return (
<div className="container sample ig-typography">
<div className="container fill">
<IgrTreeGrid
autoGenerate={false}
ref={this.treeGridRef}
id="treeGrid"
data={this.employeesFlatAvatars}
primaryKey="ID"
foreignKey="ParentID"
allowAdvancedFiltering={true}>
<IgrGridToolbar
>
<IgrGridToolbarActions
>
<IgrGridToolbarAdvancedFiltering
>
</IgrGridToolbarAdvancedFiltering>
<IgrGridToolbarHiding
>
</IgrGridToolbarHiding>
<IgrGridToolbarPinning
>
</IgrGridToolbarPinning>
<IgrGridToolbarExporter
>
</IgrGridToolbarExporter>
</IgrGridToolbarActions>
</IgrGridToolbar>
<IgrColumn
field="Name"
dataType="string"
bodyTemplate={this.webTreeGridAvatarCellTemplate}>
</IgrColumn>
<IgrColumn
field="Title"
dataType="string">
</IgrColumn>
<IgrColumn
field="ID"
dataType="number">
</IgrColumn>
<IgrColumn
field="Age"
dataType="number">
</IgrColumn>
<IgrColumn
field="HireDate"
dataType="date">
</IgrColumn>
</IgrTreeGrid>
</div>
</div>
);
}
private _employeesFlatAvatars: EmployeesFlatAvatars = null;
public get employeesFlatAvatars(): EmployeesFlatAvatars {
if (this._employeesFlatAvatars == null)
{
this._employeesFlatAvatars = new EmployeesFlatAvatars();
}
return this._employeesFlatAvatars;
}
public webTreeGridAvatarCellTemplate = (props: {dataContext: IgrCellTemplateContext}) => {
return (
<div className="cell__inner">
<IgrAvatar shape='circle' src={props.dataContext.cell.row.data.Avatar}>
</IgrAvatar>
<span className="name">{props.dataContext.cell.value}</span>
</div>
);
}
}
// rendering above component in the React DOM
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Sample/>);
tsx/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
.cell__inner {
display: flex;
align-items: center;
}
.name {
margin-left: 30px;
}
css
사전 정의된 IgrGridToolbarActions
UI IgrGridToolbarTitle
구성 요소는 내부 IgrGridToolbar
에 추가되며 이는 모두 해당 그리드 기능과의 기본 상호 작용을 제공하는 도구 모음이 필요한 데 필요합니다.
<IgrTreeGrid data={data} primaryKey="ID" foreignKey="ParentID" autoGenerate={true}>
<IgrGridToolbar>
<IgrGridToolbarTitle>
Tree Grid Toolbar
</IgrGridToolbarTitle>
<IgrGridToolbarActions>
<IgrGridToolbarAdvancedFiltering></IgrGridToolbarAdvancedFiltering>
<IgrGridToolbarPinning></IgrGridToolbarPinning>
<IgrGridToolbarHiding></IgrGridToolbarHiding>
<IgrGridToolbarExporter></IgrGridToolbarExporter>
</IgrGridToolbarActions>
</IgrGridToolbar>
</IgrTreeGrid>
tsx
위의 코드 조각에서 볼 수 있듯이 사전 정의된 Actions UI 구성 요소는 IgrGridToolbarActions 컨테이너에 래핑됩니다. 이렇게 하면 도구 모음 제목이 도구 모음 왼쪽에 정렬되고 작업이 도구 모음 오른쪽에 정렬됩니다.
물론, 각 UI는 서로 독립적으로 추가될 수도 있고 전혀 추가되지 않을 수도 있습니다. 이렇게 하면 도구 모음 컨테이너가 비어 있게 렌더링됩니다.
<IgrTreeGrid data={data} primaryKey="ID" foreignKey="ParentID" autoGenerate={true}>
<IgrGridToolbar>
</IgrGridToolbar>
</IgrTreeGrid>
tsx
각 기본 UI 구성 요소를 포괄적으로 살펴보려면 아래 기능 섹션을 계속 읽어보세요.
특징
도구 모음은 그리드 전체에 영향을 미치는 논리/상호 작용을 분리하는 데 유용합니다.
위에 표시된 대로 그리드에서 데이터 제어, 열 숨기기, 열 고정, 고급 필터링 및 내보내기를 위한 기본 구성 요소를 제공하도록 구성할 수 있습니다.
이러한 기능은 Ignite UI for React Suite의 카드 구성 요소와 유사한 패턴을 따라 서로 독립적으로 사용하도록 설정할 수 있습니다.
아래에는 도구 모음의 주요 기능과 각 기능에 대한 예제 코드가 나열되어 있습니다.
export class EmployeesFlatAvatarsItem {
public constructor(init: Partial<EmployeesFlatAvatarsItem>) {
Object.assign(this, init);
}
public Age: number;
public Avatar: string;
public HireDate: string;
public ID: number;
public Name: string;
public ParentID: number;
public Title: string;
}
export class EmployeesFlatAvatars extends Array<EmployeesFlatAvatarsItem> {
public constructor(items: Array<EmployeesFlatAvatarsItem> | number = -1) {
if (Array.isArray(items)) {
super(...items);
} else {
const newItems = [
new EmployeesFlatAvatarsItem(
{
Age: 55,
Avatar: `https://static.infragistics.com/xplatform/images/people/men/5.jpg`,
HireDate: `2008-03-20`,
ID: 1,
Name: `Johnathan Winchester`,
ParentID: -1,
Title: `Development Manager`
}),
new EmployeesFlatAvatarsItem(
{
Age: 42,
Avatar: `https://static.infragistics.com/xplatform/images/people/women/4.jpg`,
HireDate: `2014-01-22`,
ID: 4,
Name: `Ana Sanders`,
ParentID: -1,
Title: `CEO`
}),
new EmployeesFlatAvatarsItem(
{
Age: 49,
Avatar: `https://static.infragistics.com/xplatform/images/people/women/2.jpg`,
HireDate: `2014-01-22`,
ID: 18,
Name: `Victoria Lincoln`,
ParentID: -1,
Title: `Accounting Manager`
}),
new EmployeesFlatAvatarsItem(
{
Age: 61,
Avatar: `https://static.infragistics.com/xplatform/images/people/men/4.jpg`,
HireDate: `2010-01-01`,
ID: 10,
Name: `Yang Wang`,
ParentID: -1,
Title: `Localization Manager`
}),
new EmployeesFlatAvatarsItem(
{
Age: 43,
Avatar: `https://static.infragistics.com/xplatform/images/people/men/1.jpg`,
HireDate: `2011-06-03`,
ID: 3,
Name: `Michael Burke`,
ParentID: 1,
Title: `Senior Software Developer`
}),
new EmployeesFlatAvatarsItem(
{
Age: 29,
Avatar: `https://static.infragistics.com/xplatform/images/people/men/2.jpg`,
HireDate: `2009-06-19`,
ID: 2,
Name: `Thomas Anderson`,
ParentID: 1,
Title: `Senior Software Developer`
}),
new EmployeesFlatAvatarsItem(
{
Age: 31,
Avatar: `https://static.infragistics.com/xplatform/images/people/women/3.jpg`,
HireDate: `2014-08-18`,
ID: 11,
Name: `Monica Reyes`,
ParentID: 1,
Title: `Software Development Team Lead`
}),
new EmployeesFlatAvatarsItem(
{
Age: 35,
Avatar: `https://static.infragistics.com/xplatform/images/people/men/3.jpg`,
HireDate: `2015-09-17`,
ID: 6,
Name: `Roland Mendel`,
ParentID: 11,
Title: `Senior Software Developer`
}),
new EmployeesFlatAvatarsItem(
{
Age: 44,
Avatar: `https://static.infragistics.com/xplatform/images/people/men/6.jpg`,
HireDate: `2009-10-11`,
ID: 12,
Name: `Sven Cooper`,
ParentID: 11,
Title: `Senior Software Developer`
}),
new EmployeesFlatAvatarsItem(
{
Age: 44,
Avatar: `https://static.infragistics.com/xplatform/images/people/men/7.jpg`,
HireDate: `2014-04-04`,
ID: 14,
Name: `Laurence Johnson`,
ParentID: 4,
Title: `Director`
}),
new EmployeesFlatAvatarsItem(
{
Age: 25,
Avatar: `https://static.infragistics.com/xplatform/images/people/women/1.jpg`,
HireDate: `2017-11-09`,
ID: 5,
Name: `Elizabeth Richards`,
ParentID: 4,
Title: `Vice President`
}),
new EmployeesFlatAvatarsItem(
{
Age: 39,
Avatar: `https://static.infragistics.com/xplatform/images/people/men/8.jpg`,
HireDate: `2010-03-22`,
ID: 13,
Name: `Trevor Ashworth`,
ParentID: 5,
Title: `Director`
}),
new EmployeesFlatAvatarsItem(
{
Age: 44,
Avatar: `https://static.infragistics.com/xplatform/images/people/men/9.jpg`,
HireDate: `2014-04-04`,
ID: 17,
Name: `Antonio Moreno`,
ParentID: 18,
Title: `Senior Accountant`
}),
new EmployeesFlatAvatarsItem(
{
Age: 50,
Avatar: `https://static.infragistics.com/xplatform/images/people/men/10.jpg`,
HireDate: `2007-11-18`,
ID: 7,
Name: `Pedro Rodriguez`,
ParentID: 10,
Title: `Senior Localization Developer`
}),
new EmployeesFlatAvatarsItem(
{
Age: 27,
Avatar: `https://static.infragistics.com/xplatform/images/people/women/5.jpg`,
HireDate: `2016-02-19`,
ID: 8,
Name: `Casey Harper`,
ParentID: 10,
Title: `Senior Localization Developer`
}),
new EmployeesFlatAvatarsItem(
{
Age: 25,
Avatar: `https://static.infragistics.com/xplatform/images/people/women/6.jpg`,
HireDate: `2017-11-09`,
ID: 15,
Name: `Patricia Simpson`,
ParentID: 7,
Title: `Localization Intern`
}),
new EmployeesFlatAvatarsItem(
{
Age: 39,
Avatar: `https://static.infragistics.com/xplatform/images/people/men/26.jpg`,
HireDate: `2010-03-22`,
ID: 9,
Name: `Francisco Chang`,
ParentID: 7,
Title: `Localization Intern`
}),
new EmployeesFlatAvatarsItem(
{
Age: 25,
Avatar: `https://static.infragistics.com/xplatform/images/people/men/27.jpg`,
HireDate: `2018-03-18`,
ID: 16,
Name: `Peter Lewis`,
ParentID: 7,
Title: `Localization Intern`
}),
];
super(...(newItems.slice(0, items)));
}
}
}
tsimport React, { useRef } from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import {
IgrCellTemplateContext,
IgrGridToolbar,
IgrGridToolbarActions,
IgrGridToolbarAdvancedFiltering,
IgrGridToolbarExporter,
IgrGridToolbarHiding,
IgrGridToolbarPinning,
IgrGridToolbarTitle,
IgrTreeGrid,
IgrTreeGridModule,
} from "@infragistics/igniteui-react-grids";
import { IgrColumn } from "@infragistics/igniteui-react-grids";
import { IgrAvatar, IgrAvatarModule, IgrCheckboxChangeEventArgs, IgrComponentValueChangedEventArgs, IgrInput, IgrInputModule, IgrSwitch, IgrSwitchModule } from "@infragistics/igniteui-react";
import "@infragistics/igniteui-react-grids/grids/themes/light/bootstrap.css";
import { EmployeesFlatAvatars } from "./EmployeesFlatAvatars";
IgrTreeGridModule.register();
IgrAvatarModule.register();
IgrSwitchModule.register();
IgrInputModule.register();
export default function App() {
const employeesData = new EmployeesFlatAvatars();
const treeGridRef = useRef<IgrTreeGrid>(null);
function webTreeGridAvatarCellTemplate(props: {
dataContext: IgrCellTemplateContext;
}) {
return (
<div className="cell__inner">
<IgrAvatar
shape="circle"
src={props.dataContext.cell.row.data.Avatar}
></IgrAvatar>
<span className="name">{props.dataContext.cell.value}</span>
</div>
);
}
const spanRef = useRef(null);
const changeTitle = (event: IgrComponentValueChangedEventArgs) => {
spanRef.current.innerText = event.detail;
}
const enableFiltering = (e: IgrCheckboxChangeEventArgs) => {
const toolbarFiltering = document.getElementsByTagName('igc-grid-toolbar-advanced-filtering')[0] as any;
toolbarFiltering.hidden = !e.detail.checked;
};
const enableHiding = (e: IgrCheckboxChangeEventArgs) => {
const toolbarHiding = document.getElementsByTagName('igc-grid-toolbar-hiding')[0] as any;
toolbarHiding.hidden = !e.detail.checked;
};
const enablePinning = (e: IgrCheckboxChangeEventArgs) => {
const toolbarPinning = document.getElementsByTagName('igc-grid-toolbar-pinning')[0] as any;
toolbarPinning.hidden = !e.detail.checked;
};
const enableExport = (e: IgrCheckboxChangeEventArgs) => {
const toolbarExporter = document.getElementsByTagName('igc-grid-toolbar-exporter')[0] as any;
toolbarExporter.hidden = !e.detail.checked;
};
return (
<div className="container sample ig-typography">
<div className="container fill">
<div className="control_panel">
<IgrInput onInput={changeTitle} type="text" label="Toolbar title" value="Tree grid toolbar" />
<IgrSwitch onChange={enableFiltering} checked>
<span key="filtering">Advanced Filtering</span>
</IgrSwitch>
<IgrSwitch onChange={enableHiding} checked>
<span key="hiding">Column hiding</span>
</IgrSwitch>
<IgrSwitch onChange={enablePinning} checked>
<span key="pinning">Column pinning</span>
</IgrSwitch>
<IgrSwitch onChange={enableExport} checked>
<span key="exporting">Exporting</span>
</IgrSwitch>
</div>
<IgrTreeGrid
autoGenerate={false}
ref={treeGridRef}
data={employeesData}
primaryKey="ID"
foreignKey="ParentID"
>
<IgrGridToolbar key="toolbar">
<IgrGridToolbarTitle key="toolbarTitle">
<span key="toolbarTitleText" ref={spanRef}>Tree grid toolbar</span>
</IgrGridToolbarTitle>
<IgrGridToolbarActions key="toolbarActions">
<IgrGridToolbarAdvancedFiltering key="toolbarFiltering"></IgrGridToolbarAdvancedFiltering>
<IgrGridToolbarHiding key="toolbarHiding"></IgrGridToolbarHiding>
<IgrGridToolbarPinning key="toolbarPinning"></IgrGridToolbarPinning>
<IgrGridToolbarExporter key="toolbarExporter"></IgrGridToolbarExporter>
</IgrGridToolbarActions>
</IgrGridToolbar>
<IgrColumn
field="Name"
dataType="string"
bodyTemplate={webTreeGridAvatarCellTemplate}
></IgrColumn>
<IgrColumn field="Title" dataType="string"></IgrColumn>
<IgrColumn field="ID" dataType="number"></IgrColumn>
<IgrColumn field="Age" dataType="number"></IgrColumn>
<IgrColumn field="HireDate" dataType="date"></IgrColumn>
</IgrTreeGrid>
</div>
</div>
);
}
// rendering above component in the React DOM
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
tsx/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
.cell__inner {
display: flex;
align-items: center;
}
.name {
margin-left: 30px;
}
.control_panel {
width: 700px;
margin-bottom: 10px;
}
css
제목
IgrGridToolbarTitle
사용하여 그리드의 도구 모음 제목을 설정합니다.
사용자는 간단한 텍스트부터 보다 복잡한 템플릿까지 무엇이든 제공할 수 있습니다.
<IgrGridToolbar>
<IgrGridToolbarTitle>
Grid toolbar title
</IgrGridToolbarTitle>
</IgrGridToolbar>
tsx
행위
IgrGridToolbarActions
는 사용자가 상위 그리드와 관련하여 작업/상호 작용을 배치할 수 있는 곳입니다. 도구 모음의 제목 부분과 마찬가지로 사용자는 기본 도구 모음 상호 작용 구성 요소를 포함하여 해당 템플릿 부분 내에 무엇이든 제공할 수 있습니다.
<IgrGridToolbar>
<IgrGridToolbarActions>
</IgrGridToolbarActions>
</IgrGridToolbar>
tsx
열 고정
IgrGridToolbarPinning
구성 요소는 그리드의 열 고정과 상호 작용하기 위한 기본 UI를 제공합니다.
구성 요소는 구성 요소 제목, 구성 요소 입력을 위한 자리 표시자 및 드롭다운 자체의 높이와 같은 UI 사용자 정의를 위한 여러 입력 속성뿐만 아니라 도구 모음이 포함된 상위 그리드를 사용하여 즉시 작동하도록 설정됩니다.
<IgrGridToolbar>
<IgrGridToolbarActions>
<IgrGridToolbarPinning title="Grid pinned columns" prompt="Filter column collection" columnListHeight="400px"></IgrGridToolbarPinning>
</IgrGridToolbarActions>
</IgrGridToolbar>
tsx
열 숨기기
IgrGridToolbarHiding
은 열 숨기기와 상호작용하기 위한 기본 UI를 제공합니다. 구성 요소 제목, 구성 요소 입력을 위한 자리 표시자, 드롭다운 자체의 높이 등 UI 사용자 지정을 위한 동일한 입력 속성을 노출합니다.
<IgrGridToolbar>
<IgrGridToolbarActions>
<IgrGridToolbarHiding title="Grid column hiding" prompt="Filter column collection" columnListHeight="400px"></IgrGridToolbarHiding>
</IgrGridToolbarActions>
</IgrGridToolbar>
tsx
고급 필터링
도구 모음 고급 필터링 구성 요소는 고급 필터링 기능을 위한 기본 UI를 제공합니다. 구성 요소는 버튼의 기본 텍스트를 변경하는 방법을 노출합니다.
<IgrGridToolbar>
<IgrGridToolbarActions>
<IgrGridToolbarAdvancedFiltering></IgrGridToolbarAdvancedFiltering>
</IgrGridToolbarActions>
</IgrGridToolbar>
tsx
데이터 내보내기
나머지 도구 모음 작업과 마찬가지로 내보내기는 기본적으로 IgrGridToolbarExporter
를 통해 제공됩니다.
도구 모음 내보내기 구성 요소는 UI와 내보내기 환경을 모두 사용자 지정하기 위한 여러 입력 속성을 노출합니다.
표시 텍스트 변경부터 드롭다운 옵션 활성화/비활성화, 생성된 파일 이름 사용자 정의까지 다양합니다. 자세한 내용은 ToolbarExporter
에 대한 API 문서를 참조하세요.
다음은 React 템플릿을 통해 사용자 정의할 수 있는 몇 가지 옵션을 보여주는 스니펫입니다.
<IgrGridToolbar>
<IgrGridToolbarActions>
<IgrGridToolbarExporter exportCSV={true} exportExcel={true} filename="exported_data"></IgrGridToolbarExporter>
</IgrGridToolbarActions>
</IgrGridToolbar>
tsx
내보낸 파일 이름을 변경하는 것 외에도 사용자는 ToolbarExporting
이벤트를 기다리고 이벤트 속성에서 옵션 항목을 사용자 정의하여 내보내기 옵션을 추가로 구성할 수 있습니다.
기본적으로 CSV로 내보낼 때 내보내기는 쉼표 구분 기호를 사용하여 내보내고 출력 파일에 '.csv' 확장자를 사용합니다. 내보내기 이벤트를 구독하거나 내보내기 옵션 필드의 값을 변경하여 이러한 내보내기 매개변수를 사용자 정의할 수 있습니다. 이벤트 인수의 취소 필드를 true로 설정하여 내보내기 프로세스를 취소할 수도 있습니다.
다음 코드 조각은 도구 모음 내보내기 이벤트를 구독하고 내보내기 옵션을 구성하는 방법을 보여줍니다.
const configureExport = (evt: IgrGridToolbarExportEventArgs) => {
const args = evt.detail;
const options: IgrExporterOptionsBase = args.options;
options.fileName = `Report_${new Date().toDateString()}`;
(args.exporter as any).columnExporting.subscribe((columnArgs: any) => {
columnArgs.cancel = columnArgs.header === 'Name';
});
}
<IgrTreeGrid onToolbarExporting={configureExport}>
</IgrTreeGrid>
tsx
다음 샘플은 내보낸 파일을 사용자 정의하는 방법을 보여줍니다.
export class EmployeesFlatAvatarsItem {
public constructor(init: Partial<EmployeesFlatAvatarsItem>) {
Object.assign(this, init);
}
public Age: number;
public Avatar: string;
public HireDate: string;
public ID: number;
public Name: string;
public ParentID: number;
public Title: string;
}
export class EmployeesFlatAvatars extends Array<EmployeesFlatAvatarsItem> {
public constructor(items: Array<EmployeesFlatAvatarsItem> | number = -1) {
if (Array.isArray(items)) {
super(...items);
} else {
const newItems = [
new EmployeesFlatAvatarsItem({ Age: 55, Avatar: `https://static.infragistics.com/xplatform/images/people/men/5.jpg`, HireDate: `2008-03-20`, ID: 1, Name: `Johnathan Winchester`, ParentID: -1, Title: `Development Manager` }),
new EmployeesFlatAvatarsItem({ Age: 42, Avatar: `https://static.infragistics.com/xplatform/images/people/women/4.jpg`, HireDate: `2014-01-22`, ID: 4, Name: `Ana Sanders`, ParentID: -1, Title: `CEO` }),
new EmployeesFlatAvatarsItem({ Age: 49, Avatar: `https://static.infragistics.com/xplatform/images/people/women/2.jpg`, HireDate: `2014-01-22`, ID: 18, Name: `Victoria Lincoln`, ParentID: -1, Title: `Accounting Manager` }),
new EmployeesFlatAvatarsItem({ Age: 61, Avatar: `https://static.infragistics.com/xplatform/images/people/men/4.jpg`, HireDate: `2010-01-01`, ID: 10, Name: `Yang Wang`, ParentID: -1, Title: `Localization Manager` }),
new EmployeesFlatAvatarsItem({ Age: 43, Avatar: `https://static.infragistics.com/xplatform/images/people/men/1.jpg`, HireDate: `2011-06-03`, ID: 3, Name: `Michael Burke`, ParentID: 1, Title: `Senior Software Developer` }),
new EmployeesFlatAvatarsItem({ Age: 29, Avatar: `https://static.infragistics.com/xplatform/images/people/men/2.jpg`, HireDate: `2009-06-19`, ID: 2, Name: `Thomas Anderson`, ParentID: 1, Title: `Senior Software Developer` }),
new EmployeesFlatAvatarsItem({ Age: 31, Avatar: `https://static.infragistics.com/xplatform/images/people/women/3.jpg`, HireDate: `2014-08-18`, ID: 11, Name: `Monica Reyes`, ParentID: 1, Title: `Software Development Team Lead` }),
new EmployeesFlatAvatarsItem({ Age: 35, Avatar: `https://static.infragistics.com/xplatform/images/people/men/3.jpg`, HireDate: `2015-09-17`, ID: 6, Name: `Roland Mendel`, ParentID: 11, Title: `Senior Software Developer` }),
new EmployeesFlatAvatarsItem({ Age: 44, Avatar: `https://static.infragistics.com/xplatform/images/people/men/6.jpg`, HireDate: `2009-10-11`, ID: 12, Name: `Sven Cooper`, ParentID: 11, Title: `Senior Software Developer` }),
new EmployeesFlatAvatarsItem({ Age: 44, Avatar: `https://static.infragistics.com/xplatform/images/people/men/7.jpg`, HireDate: `2014-04-04`, ID: 14, Name: `Laurence Johnson`, ParentID: 4, Title: `Director` }),
new EmployeesFlatAvatarsItem({ Age: 25, Avatar: `https://static.infragistics.com/xplatform/images/people/women/1.jpg`, HireDate: `2017-11-09`, ID: 5, Name: `Elizabeth Richards`, ParentID: 4, Title: `Vice President` }),
new EmployeesFlatAvatarsItem({ Age: 39, Avatar: `https://static.infragistics.com/xplatform/images/people/men/8.jpg`, HireDate: `2010-03-22`, ID: 13, Name: `Trevor Ashworth`, ParentID: 5, Title: `Director` }),
new EmployeesFlatAvatarsItem({ Age: 44, Avatar: `https://static.infragistics.com/xplatform/images/people/men/9.jpg`, HireDate: `2014-04-04`, ID: 17, Name: `Antonio Moreno`, ParentID: 18, Title: `Senior Accountant` }),
new EmployeesFlatAvatarsItem({ Age: 50, Avatar: `https://static.infragistics.com/xplatform/images/people/men/10.jpg`, HireDate: `2007-11-18`, ID: 7, Name: `Pedro Rodriguez`, ParentID: 10, Title: `Senior Localization Developer` }),
new EmployeesFlatAvatarsItem({ Age: 27, Avatar: `https://static.infragistics.com/xplatform/images/people/women/5.jpg`, HireDate: `2016-02-19`, ID: 8, Name: `Casey Harper`, ParentID: 10, Title: `Senior Localization Developer` }),
new EmployeesFlatAvatarsItem({ Age: 25, Avatar: `https://static.infragistics.com/xplatform/images/people/women/6.jpg`, HireDate: `2017-11-09`, ID: 15, Name: `Patricia Simpson`, ParentID: 7, Title: `Localization Intern` }),
new EmployeesFlatAvatarsItem({ Age: 39, Avatar: `https://static.infragistics.com/xplatform/images/people/men/26.jpg`, HireDate: `2010-03-22`, ID: 9, Name: `Francisco Chang`, ParentID: 7, Title: `Localization Intern` }),
new EmployeesFlatAvatarsItem({ Age: 25, Avatar: `https://static.infragistics.com/xplatform/images/people/men/27.jpg`, HireDate: `2018-03-18`, ID: 16, Name: `Peter Lewis`, ParentID: 7, Title: `Localization Intern` }),
];
super(...newItems.slice(0));
}
}
}
tsimport React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrTreeGridModule } from "@infragistics/igniteui-react-grids";
import { IgrAvatarModule } from "@infragistics/igniteui-react";
import { IgrTreeGrid, IgrGridToolbar, IgrGridToolbarActions, IgrGridToolbarExporter, IgrColumn } from "@infragistics/igniteui-react-grids";
import { EmployeesFlatAvatarsItem, EmployeesFlatAvatars } from './EmployeesFlatAvatars';
import { IgrExporterOptionsBase, IgrGridToolbarExportEventArgs } from "@infragistics/igniteui-react-grids";
import { IgrAvatar } from "@infragistics/igniteui-react";
import { IgrCellTemplateContext } from "@infragistics/igniteui-react-grids";
import "@infragistics/igniteui-react-grids/grids/themes/light/bootstrap.css";
const mods: any[] = [
IgrTreeGridModule,
IgrAvatarModule
];
mods.forEach((m) => m.register());
export default class Sample extends React.Component<any, any> {
private treeGrid: IgrTreeGrid
private treeGridRef(r: IgrTreeGrid) {
this.treeGrid = r;
this.setState({});
}
constructor(props: any) {
super(props);
this.treeGridRef = this.treeGridRef.bind(this);
this.webTreeGridToolbarExporting = this.webTreeGridToolbarExporting.bind(this);
}
public render(): JSX.Element {
return (
<div className="container sample ig-typography">
<div className="container fill">
<IgrTreeGrid
autoGenerate={false}
ref={this.treeGridRef}
id="treeGrid"
data={this.employeesFlatAvatars}
primaryKey="ID"
foreignKey="ParentID"
onToolbarExporting={this.webTreeGridToolbarExporting}>
<IgrGridToolbar
>
<IgrGridToolbarActions
>
<IgrGridToolbarExporter
>
</IgrGridToolbarExporter>
</IgrGridToolbarActions>
</IgrGridToolbar>
<IgrColumn
field="Name"
dataType="string"
bodyTemplate={this.webTreeGridAvatarCellTemplate}>
</IgrColumn>
<IgrColumn
field="Title"
dataType="string">
</IgrColumn>
<IgrColumn
field="ID"
dataType="number">
</IgrColumn>
<IgrColumn
field="Age"
dataType="number">
</IgrColumn>
<IgrColumn
field="HireDate"
dataType="date">
</IgrColumn>
</IgrTreeGrid>
</div>
</div>
);
}
private _employeesFlatAvatars: EmployeesFlatAvatars = null;
public get employeesFlatAvatars(): EmployeesFlatAvatars {
if (this._employeesFlatAvatars == null)
{
this._employeesFlatAvatars = new EmployeesFlatAvatars();
}
return this._employeesFlatAvatars;
}
public webTreeGridToolbarExporting(evt: IgrGridToolbarExportEventArgs): void {
const args = evt.detail;
const options: IgrExporterOptionsBase = args.options;
if (options) {
options.fileName = `Report_${new Date().toDateString()}`;
(args.exporter as any).columnExporting.subscribe((columnArgs: any) => {
columnArgs.cancel = columnArgs.header === 'Name';
});
}
}
public webTreeGridAvatarCellTemplate = (props: {dataContext: IgrCellTemplateContext}) => {
return (
<div className="cell__inner">
<IgrAvatar shape='circle' src={props.dataContext.cell.row.data.Avatar}>
</IgrAvatar>
<span className="name">{props.dataContext.cell.value}</span>
</div>
);
}
}
// rendering above component in the React DOM
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Sample/>);
tsx/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
.cell__inner {
display: flex;
align-items: center;
}
.name {
margin-left: 30px;
}
css
지표 내보내기
기본 도구 모음 내보내기 구성 요소를 사용하는 경우 내보내기 작업이 발생할 때마다 작업이 진행되는 동안 도구 모음에 진행률 표시기가 표시됩니다.
또한 사용자는 도구 모음 showProgress
속성을 설정하고 장기 실행 작업에 사용하거나 그리드에서 발생하는 작업을 나타내는 또 다른 방법으로 사용할 수 있습니다.
아래 샘플에는 진행률 표시줄을 볼 수 있도록 데이터 내보내기에 필요한 시간을 늘리기 위해 상당한 양의 데이터가 사용됩니다. 또한 그리드에서 장기 실행 작업을 시뮬레이션하는 또 다른 버튼이 있습니다.
export class OrdersTreeDataItem {
public constructor(init: Partial<OrdersTreeDataItem>) {
Object.assign(this, init);
}
public ID: number;
public ParentID: number;
public Name: string;
public Category: string;
public OrderDate: string;
public Units: number;
public UnitPrice: number;
public Price: number;
public Delivered: boolean;
}
export class OrdersTreeData extends Array<OrdersTreeDataItem> {
public constructor(items: Array<OrdersTreeDataItem> | number = -1) {
if (Array.isArray(items)) {
super(...items);
} else {
const newItems = [
new OrdersTreeDataItem(
{
ID: 1,
ParentID: -1,
Name: `Order 1`,
Category: ``,
OrderDate: `2010-02-17`,
Units: 1844,
UnitPrice: 3.73,
Price: 6884.38,
Delivered: true
}),
new OrdersTreeDataItem(
{
ID: 101,
ParentID: 1,
Name: `Chocolate Chip Cookies`,
Category: `Cookies`,
OrderDate: `2010-02-17`,
Units: 834,
UnitPrice: 3.59,
Price: 2994.06,
Delivered: true
}),
new OrdersTreeDataItem(
{
ID: 102,
ParentID: 1,
Name: `Red Apples`,
Category: `Fruit`,
OrderDate: `2010-02-17`,
Units: 371,
UnitPrice: 3.66,
Price: 1357.86,
Delivered: true
}),
new OrdersTreeDataItem(
{
ID: 103,
ParentID: 1,
Name: `Butter`,
Category: `Diary`,
OrderDate: `2010-02-17`,
Units: 260,
UnitPrice: 3.45,
Price: 897,
Delivered: true
}),
new OrdersTreeDataItem(
{
ID: 104,
ParentID: 1,
Name: `Potato Chips`,
Category: `Snack`,
OrderDate: `2010-02-17`,
Units: 118,
UnitPrice: 1.96,
Price: 231.28,
Delivered: true
}),
new OrdersTreeDataItem(
{
ID: 105,
ParentID: 1,
Name: `Orange Juice`,
Category: `Beverages`,
OrderDate: `2010-02-17`,
Units: 261,
UnitPrice: 5.38,
Price: 1404.18,
Delivered: true
}),
new OrdersTreeDataItem(
{
ID: 2,
ParentID: -1,
Name: `Order 2`,
Category: ``,
OrderDate: `2022-05-27`,
Units: 1831,
UnitPrice: 8.23,
Price: 15062.77,
Delivered: false
}),
new OrdersTreeDataItem(
{
ID: 201,
ParentID: 2,
Name: `Frozen Shrimps`,
Category: `Seafood`,
OrderDate: `2022-05-27`,
Units: 120,
UnitPrice: 20.45,
Price: 2454,
Delivered: false
}),
new OrdersTreeDataItem(
{
ID: 202,
ParentID: 2,
Name: `Ice Tea`,
Category: `Beverages`,
OrderDate: `2022-05-27`,
Units: 840,
UnitPrice: 7,
Price: 5880,
Delivered: false
}),
new OrdersTreeDataItem(
{
ID: 203,
ParentID: 2,
Name: `Fresh Cheese`,
Category: `Diary`,
OrderDate: `2022-05-27`,
Units: 267,
UnitPrice: 16.55,
Price: 4418.85,
Delivered: false
}),
new OrdersTreeDataItem(
{
ID: 204,
ParentID: 2,
Name: `Carrots`,
Category: `Vegetables`,
OrderDate: `2022-05-27`,
Units: 360,
UnitPrice: 2.77,
Price: 997.2,
Delivered: false
}),
new OrdersTreeDataItem(
{
ID: 205,
ParentID: 2,
Name: `Apple Juice`,
Category: `Beverages`,
OrderDate: `2022-05-27`,
Units: 244,
UnitPrice: 5.38,
Price: 1312.72,
Delivered: false
}),
new OrdersTreeDataItem(
{
ID: 3,
ParentID: -1,
Name: `Order 3`,
Category: ``,
OrderDate: `2022-08-04`,
Units: 1972,
UnitPrice: 3.47,
Price: 6849.18,
Delivered: true
}),
new OrdersTreeDataItem(
{
ID: 301,
ParentID: 3,
Name: `Skimmed Milk 1L`,
Category: `Diary`,
OrderDate: `2022-08-04`,
Units: 1028,
UnitPrice: 3.56,
Price: 3659.68,
Delivered: true
}),
new OrdersTreeDataItem(
{
ID: 302,
ParentID: 3,
Name: `Bananas 5 Pack`,
Category: `Fruit`,
OrderDate: `2022-08-04`,
Units: 370,
UnitPrice: 6.36,
Price: 2353.2,
Delivered: true
}),
new OrdersTreeDataItem(
{
ID: 303,
ParentID: 3,
Name: `Cauliflower`,
Category: `Vegetables`,
OrderDate: `2022-08-04`,
Units: 283,
UnitPrice: 0.95,
Price: 268.85,
Delivered: true
}),
new OrdersTreeDataItem(
{
ID: 304,
ParentID: 3,
Name: `White Chocolate Cookies`,
Category: `Cookies`,
OrderDate: `2022-08-04`,
Units: 291,
UnitPrice: 1.95,
Price: 567.45,
Delivered: true
}),
new OrdersTreeDataItem(
{
ID: 4,
ParentID: -1,
Name: `Order 4`,
Category: ``,
OrderDate: `2023-01-04`,
Units: 1065,
UnitPrice: 5.56,
Price: 5923.5,
Delivered: true
}),
new OrdersTreeDataItem(
{
ID: 401,
ParentID: 4,
Name: `Mini Milk Chocolate Cookie Bites`,
Category: `Cookies`,
OrderDate: `2023-01-04`,
Units: 68,
UnitPrice: 2.25,
Price: 153,
Delivered: true
}),
new OrdersTreeDataItem(
{
ID: 402,
ParentID: 4,
Name: `Wild Salmon Fillets`,
Category: `Seafood`,
OrderDate: `2023-01-04`,
Units: 320,
UnitPrice: 16.15,
Price: 5168,
Delivered: true
}),
new OrdersTreeDataItem(
{
ID: 403,
ParentID: 4,
Name: `Diet Lemonade`,
Category: `Beverages`,
OrderDate: `2023-01-04`,
Units: 437,
UnitPrice: 0.5,
Price: 218.5,
Delivered: true
}),
new OrdersTreeDataItem(
{
ID: 404,
ParentID: 4,
Name: `Potatos`,
Category: `Vegetables`,
OrderDate: `2023-01-04`,
Units: 240,
UnitPrice: 1.6,
Price: 384,
Delivered: true
}),
];
super(...(newItems.slice(0, items)));
}
}
}
tsimport React, { useRef } from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import {
IgrGridToolbar,
IgrGridToolbarActions,
IgrGridToolbarExporter,
IgrGridToolbarTitle,
IgrHierarchicalGridModule,
} from "@infragistics/igniteui-react-grids";
import {
IgrTreeGrid,
IgrColumn,
} from "@infragistics/igniteui-react-grids";
import { IgrButton } from "@infragistics/igniteui-react";
import "@infragistics/igniteui-react-grids/grids/themes/light/bootstrap.css";
import { OrdersTreeData } from "./OrdersData";
IgrHierarchicalGridModule.register();
export default function App() {
const ordersData = new OrdersTreeData();
const treeGridRef = useRef<IgrTreeGrid>(null);
const toolbarRef = useRef<IgrGridToolbar>(null);
const localData: any[] = [];
for (let i = 0; i < 10000; i += 3) {
for (let c = 0; c < ordersData.length; c++) {
localData.push(ordersData[c]);
}
}
function showProgress() {
toolbarRef.current.showProgress = true;
setTimeout(() => {
toolbarRef.current.showProgress = false;
}, 5000);
}
return (
<div className="container sample ig-typography">
<div className="container fill">
<IgrTreeGrid
ref={treeGridRef}
data={localData}
autoGenerate={false}
primaryKey="ID"
foreignKey="ParentID"
height="350px"
>
<IgrGridToolbar ref={toolbarRef} key="toolbar">
<IgrGridToolbarTitle key="toolbarTitle">
<span key="toolbarTitleText">Tree Grid Toolbar</span>
</IgrGridToolbarTitle>
<IgrButton key="btn" onClick={showProgress}>
<span key="simulate">Simulate long running operation</span>
</IgrButton>
<IgrGridToolbarActions key="toolbarActions">
<IgrGridToolbarExporter key="toolbarExporter"></IgrGridToolbarExporter>
</IgrGridToolbarActions>
</IgrGridToolbar>
<IgrColumn field="ID" header="Order ID"></IgrColumn>
<IgrColumn field="Name" header="Order Product"></IgrColumn>
<IgrColumn field="Category" header="Category"></IgrColumn>
<IgrColumn field="Units" header="Units" dataType="number"></IgrColumn>
<IgrColumn field="UnitPrice" header="Unit Price" dataType="currency"></IgrColumn>
<IgrColumn field="Price" header="Price" dataType="currency"></IgrColumn>
<IgrColumn field="OrderDate" header="Order Date" dataType="date"></IgrColumn>
</IgrTreeGrid>
</div>
</div>
);
}
// rendering above component in the React DOM
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
tsx/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
css
스타일링
사전 정의된 테마 외에도 사용 가능한 CSS 속성 중 일부를 설정하여 그리드를 추가로 사용자 정의할 수 있습니다. 일부 색상을 변경하려면 먼저 그리드에 대한 클래스를 설정해야 합니다.
<IgrTreeGrid className="grid"></IgrTreeGrid>
tsx
그런 다음 해당 클래스에 대한 관련 CSS 속성을 설정합니다.
.grid {
--ig-grid-toolbar-background-color: #2a2b2f;
--ig-grid-toolbar-title-text-color: #ffcd0f;
--ig-grid-toolbar-dropdown-background: #2a2b2f;
}
css
데모
export class EmployeesFlatAvatarsItem {
public constructor(init: Partial<EmployeesFlatAvatarsItem>) {
Object.assign(this, init);
}
public Age: number;
public Avatar: string;
public HireDate: string;
public ID: number;
public Name: string;
public ParentID: number;
public Title: string;
}
export class EmployeesFlatAvatars extends Array<EmployeesFlatAvatarsItem> {
public constructor(items: Array<EmployeesFlatAvatarsItem> | number = -1) {
if (Array.isArray(items)) {
super(...items);
} else {
const newItems = [
new EmployeesFlatAvatarsItem({ Age: 55, Avatar: `https://static.infragistics.com/xplatform/images/people/men/5.jpg`, HireDate: `2008-03-20`, ID: 1, Name: `Johnathan Winchester`, ParentID: -1, Title: `Development Manager` }),
new EmployeesFlatAvatarsItem({ Age: 42, Avatar: `https://static.infragistics.com/xplatform/images/people/women/4.jpg`, HireDate: `2014-01-22`, ID: 4, Name: `Ana Sanders`, ParentID: -1, Title: `CEO` }),
new EmployeesFlatAvatarsItem({ Age: 49, Avatar: `https://static.infragistics.com/xplatform/images/people/women/2.jpg`, HireDate: `2014-01-22`, ID: 18, Name: `Victoria Lincoln`, ParentID: -1, Title: `Accounting Manager` }),
new EmployeesFlatAvatarsItem({ Age: 61, Avatar: `https://static.infragistics.com/xplatform/images/people/men/4.jpg`, HireDate: `2010-01-01`, ID: 10, Name: `Yang Wang`, ParentID: -1, Title: `Localization Manager` }),
new EmployeesFlatAvatarsItem({ Age: 43, Avatar: `https://static.infragistics.com/xplatform/images/people/men/1.jpg`, HireDate: `2011-06-03`, ID: 3, Name: `Michael Burke`, ParentID: 1, Title: `Senior Software Developer` }),
new EmployeesFlatAvatarsItem({ Age: 29, Avatar: `https://static.infragistics.com/xplatform/images/people/men/2.jpg`, HireDate: `2009-06-19`, ID: 2, Name: `Thomas Anderson`, ParentID: 1, Title: `Senior Software Developer` }),
new EmployeesFlatAvatarsItem({ Age: 31, Avatar: `https://static.infragistics.com/xplatform/images/people/women/3.jpg`, HireDate: `2014-08-18`, ID: 11, Name: `Monica Reyes`, ParentID: 1, Title: `Software Development Team Lead` }),
new EmployeesFlatAvatarsItem({ Age: 35, Avatar: `https://static.infragistics.com/xplatform/images/people/men/3.jpg`, HireDate: `2015-09-17`, ID: 6, Name: `Roland Mendel`, ParentID: 11, Title: `Senior Software Developer` }),
new EmployeesFlatAvatarsItem({ Age: 44, Avatar: `https://static.infragistics.com/xplatform/images/people/men/6.jpg`, HireDate: `2009-10-11`, ID: 12, Name: `Sven Cooper`, ParentID: 11, Title: `Senior Software Developer` }),
new EmployeesFlatAvatarsItem({ Age: 44, Avatar: `https://static.infragistics.com/xplatform/images/people/men/7.jpg`, HireDate: `2014-04-04`, ID: 14, Name: `Laurence Johnson`, ParentID: 4, Title: `Director` }),
new EmployeesFlatAvatarsItem({ Age: 25, Avatar: `https://static.infragistics.com/xplatform/images/people/women/1.jpg`, HireDate: `2017-11-09`, ID: 5, Name: `Elizabeth Richards`, ParentID: 4, Title: `Vice President` }),
new EmployeesFlatAvatarsItem({ Age: 39, Avatar: `https://static.infragistics.com/xplatform/images/people/men/8.jpg`, HireDate: `2010-03-22`, ID: 13, Name: `Trevor Ashworth`, ParentID: 5, Title: `Director` }),
new EmployeesFlatAvatarsItem({ Age: 44, Avatar: `https://static.infragistics.com/xplatform/images/people/men/9.jpg`, HireDate: `2014-04-04`, ID: 17, Name: `Antonio Moreno`, ParentID: 18, Title: `Senior Accountant` }),
new EmployeesFlatAvatarsItem({ Age: 50, Avatar: `https://static.infragistics.com/xplatform/images/people/men/10.jpg`, HireDate: `2007-11-18`, ID: 7, Name: `Pedro Rodriguez`, ParentID: 10, Title: `Senior Localization Developer` }),
new EmployeesFlatAvatarsItem({ Age: 27, Avatar: `https://static.infragistics.com/xplatform/images/people/women/5.jpg`, HireDate: `2016-02-19`, ID: 8, Name: `Casey Harper`, ParentID: 10, Title: `Senior Localization Developer` }),
new EmployeesFlatAvatarsItem({ Age: 25, Avatar: `https://static.infragistics.com/xplatform/images/people/women/6.jpg`, HireDate: `2017-11-09`, ID: 15, Name: `Patricia Simpson`, ParentID: 7, Title: `Localization Intern` }),
new EmployeesFlatAvatarsItem({ Age: 39, Avatar: `https://static.infragistics.com/xplatform/images/people/men/26.jpg`, HireDate: `2010-03-22`, ID: 9, Name: `Francisco Chang`, ParentID: 7, Title: `Localization Intern` }),
new EmployeesFlatAvatarsItem({ Age: 25, Avatar: `https://static.infragistics.com/xplatform/images/people/men/27.jpg`, HireDate: `2018-03-18`, ID: 16, Name: `Peter Lewis`, ParentID: 7, Title: `Localization Intern` }),
];
super(...newItems.slice(0));
}
}
}
tsimport React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrTreeGridModule } from "@infragistics/igniteui-react-grids";
import { IgrAvatarModule } from "@infragistics/igniteui-react";
import { IgrTreeGrid, IgrGridToolbar, IgrGridToolbarActions, IgrGridToolbarAdvancedFiltering, IgrGridToolbarHiding, IgrGridToolbarPinning, IgrGridToolbarExporter, IgrColumn } from "@infragistics/igniteui-react-grids";
import { EmployeesFlatAvatarsItem, EmployeesFlatAvatars } from './EmployeesFlatAvatars';
import { IgrAvatar } from "@infragistics/igniteui-react";
import { IgrCellTemplateContext } from "@infragistics/igniteui-react-grids";
import "@infragistics/igniteui-react-grids/grids/themes/light/bootstrap.css";
const mods: any[] = [
IgrTreeGridModule,
IgrAvatarModule
];
mods.forEach((m) => m.register());
export default class Sample extends React.Component<any, any> {
private grid: IgrTreeGrid
private gridRef(r: IgrTreeGrid) {
this.grid = r;
this.setState({});
}
constructor(props: any) {
super(props);
this.gridRef = this.gridRef.bind(this);
}
public render(): JSX.Element {
return (
<div className="container sample ig-typography">
<div className="container fill">
<IgrTreeGrid
autoGenerate={false}
ref={this.gridRef}
id="grid"
data={this.employeesFlatAvatars}
primaryKey="ID"
foreignKey="ParentID"
allowAdvancedFiltering={true}>
<IgrGridToolbar
>
<IgrGridToolbarActions
>
<IgrGridToolbarAdvancedFiltering
>
</IgrGridToolbarAdvancedFiltering>
<IgrGridToolbarHiding
>
</IgrGridToolbarHiding>
<IgrGridToolbarPinning
>
</IgrGridToolbarPinning>
<IgrGridToolbarExporter
>
</IgrGridToolbarExporter>
</IgrGridToolbarActions>
</IgrGridToolbar>
<IgrColumn
field="Name"
dataType="string"
bodyTemplate={this.webTreeGridAvatarCellTemplate}>
</IgrColumn>
<IgrColumn
field="Title"
dataType="string">
</IgrColumn>
<IgrColumn
field="ID"
dataType="number">
</IgrColumn>
<IgrColumn
field="Age"
dataType="number">
</IgrColumn>
<IgrColumn
field="HireDate"
dataType="date">
</IgrColumn>
</IgrTreeGrid>
</div>
</div>
);
}
private _employeesFlatAvatars: EmployeesFlatAvatars = null;
public get employeesFlatAvatars(): EmployeesFlatAvatars {
if (this._employeesFlatAvatars == null)
{
this._employeesFlatAvatars = new EmployeesFlatAvatars();
}
return this._employeesFlatAvatars;
}
public webTreeGridAvatarCellTemplate = (props: {dataContext: IgrCellTemplateContext}) => {
return (
<div className="cell__inner">
<IgrAvatar shape='circle' src={props.dataContext.cell.row.data.Avatar}>
</IgrAvatar>
<span className="name">{props.dataContext.cell.value}</span>
</div>
);
}
}
// rendering above component in the React DOM
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Sample/>);
tsx/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
.cell__inner {
display: flex;
align-items: center;
}
.name {
margin-left: 30px;
}
#grid {
--ig-grid-toolbar-background-color: #2a2b2f;
--ig-grid-toolbar-title-text-color: #ffcd0f;
--ig-grid-toolbar-dropdown-background: #2a2b2f;
}
css
API 참조
Grid Toolbar 서비스에는 아래에 나열된 몇 가지 API가 더 있습니다.
IgrGridToolbarAdvancedFiltering
IgrGridToolbar
IgrGridToolbarExporter
IgrGridToolbarHiding
IgrGridToolbarPinning
IgrGridToolbarTitle
IgrTreeGrid
Events:
ToolbarExporting
추가 리소스
우리 커뮤니티는 활동적이며 항상 새로운 아이디어를 환영합니다.