React Grid 상태 지속성
React Grid의 Ignite UI for React 사용하면 개발자가 그리드 상태를 쉽게 저장하고 복원할 수 있습니다. IgrGridState
가 React IgrGrid
에 적용되면 개발자가 모든 시나리오에서 상태 지속성을 달성하는 데 사용할 수 있는 GetState
, GetStateAsString
, ApplyState
및 ApplyStateFromString
메서드가 노출됩니다.
지원되는 기능
IgrGridState
지시문은 다음 기능의 상태 저장 및 복원을 지원합니다.
- 정렬
- 필터링
- 고급 필터링
- 페이징
- CellSelection
- 행 선택
- ColumnSelection
- RowPinning
- 확장
- 그룹화 기준
- Columns
- Multi column headers
- 열 순서
- Column properties defined by the
IColumnState
interface.
용법
이 메서드는 getState
모든 상태 정보를 포함하는 개체의 그리드 상태를 IgrGridStateInfo
반환합니다. 저장하려면 추가 단계가 필요할 수 있습니다.
직렬화 된 JSON 문자열을 GetStateAsString
반환하므로 개발자는 이를 가져와 모든 데이터 저장소(데이터베이스, 클라우드, 브라우저 localStorage 등)에 저장할 수 있습니다.
개발자는 기능 이름이 있는 배열을 인수로 전달하여 특정 기능에 대한 상태만 가져오도록 선택할 수 있습니다. 빈 배열은 기본 상태 옵션을 사용하게 됩니다.
<IgrGrid>
<IgrGridState ref={gridStateRef}></IgrGridState>
</IgrGrid>
tsx
// get an `IgrGridStateInfo` object, containing all features original state objects, as returned by the grid public API
const state: IgrGridStateInfo = gridStateRef.current.getState([]);
// get all features` state in a serialized JSON string
const stateString: string = gridStateRef.current.getStateAsString([]);
// get the sorting and filtering expressions
const sortingFilteringStates: IgrGridStateInfo = gridStateRef.current.getState(['sorting', 'filtering']);
tsx
ApplyState
- 이 메서드는 객체를 인수로 받아들이고 IgrGridStateInfo
객체 또는 지정된 기능에서 찾은 각 기능의 상태를 두 번째 인수로 복원합니다.
ApplyStateFromString
- 이 메서드는 직렬화된 JSON 문자열을 인수로 허용하고 JSON 문자열에 있는 각 기능 또는 지정된 기능의 상태를 두 번째 인수로 복원합니다.
gridStateRef.current.applyState(gridState, []);
gridStateRef.current.applyStateFromString(gridStateString, []);
gridStateRef.current.applyState(sortingFilteringStates, [])
tsx
객체는 Options
인터페이스를 구현 IgrGridStateOptions
합니다, 즉, 특정 기능의 이름인 모든 키에 대해 이 기능 상태가 추적되는지 여부를 나타내는 부울 값이 있습니다. GetState
/ GetStateAsString
methods는 이러한 기능의 상태를 반환된 값에 넣지 않으며 ApplyState
/ ApplyStateFromString
methods는 해당 기능의 상태를 복원하지 않습니다.
<IgrGridState options={{ cellSelection: false, sorting: false }}></IgrGridState>
tsx
사용하기 쉬운 단일 지점 API를 사용하면 몇 줄의 코드로 전체 상태 유지 기능을 얻을 수 있습니다. 아래에서 코드를 복사하여 붙여 넣 으십시오 - 사용자가 현재 페이지를 떠날 때마다 브라우저 LocalStorage
개체에 그리드 상태를 저장합니다. 사용자가 기본 페이지로 돌아갈 때마다 그리드 상태가 복원됩니다. 더 이상 원하는 데이터를 얻기 위해 매번 복잡한 고급 필터링 및 정렬 표현식을 구성할 필요가 없습니다 - 한 번만 수행하고 아래 코드가 사용자를 위해 나머지 작업을 수행하도록 합니다.
<IgrGrid onRendered={restoreGridState}>
<IgrGridState ref={gridStateRef}></IgrGridState>
</IgrGrid>
tsx
useEffect(() => {
restoreGridState();
window.addEventListener('beforeunload', saveGridState);
return () => {
window.removeEventListener('beforeunload', saveGridState);
}
}, []);
// Using methods that work with IgrGridStateInfo object.
const saveGridState = () => {
const state = gridStateRef.current.getState([]);
window.localStorage.setItem('grid-state', JSON.stringify(state));
}
const restoreGridState = () => {
const state = window.localStorage.getItem('grid-state');
if (state) {
gridStateRef.current.applyState(JSON.parse(state), []);
}
}
//Or using string alternative methods.
const saveGridState = () => {
const state = gridStateRef.current.getStateAsString([]);
window.localStorage.setItem('grid-state', state);
}
const restoreGridState = () => {
const state = window.localStorage.getItem('grid-state');
if (state) {
gridStateRef.current.applyStateFromString(state, []);
}
}
tsx
데모
export class CustomersDataItem {
public constructor(init: Partial<CustomersDataItem>) {
Object.assign(this, init);
}
public ID: string;
public CompanyName: string;
public ContactName: string;
public ContactTitle: string;
public Address: string;
public City: string;
public Region: string;
public PostalCode: string;
public Country: string;
public Phone: string;
public Fax: string;
}
export class CustomersData extends Array<CustomersDataItem> {
public constructor() {
super();
this.push(new CustomersDataItem(
{
ID: `ALFKI`,
CompanyName: `Alfreds Futterkiste`,
ContactName: `Maria Anders`,
ContactTitle: `Sales Representative`,
Address: `Obere Str. 57`,
City: `Berlin`,
Region: `East`,
PostalCode: `12209`,
Country: `Germany`,
Phone: `030-0074321`,
Fax: `030-0076545`
}));
this.push(new CustomersDataItem(
{
ID: `ANATR`,
CompanyName: `Ana Trujillo Emparedados y helados`,
ContactName: `Ana Trujillo`,
ContactTitle: `Owner`,
Address: `Avda. de la Constitución 2222`,
City: `México D.F.`,
Region: `South`,
PostalCode: `05021`,
Country: `Mexico`,
Phone: `(5) 555-4729`,
Fax: `(5) 555-3745`
}));
this.push(new CustomersDataItem(
{
ID: `ANTON`,
CompanyName: `Antonio Moreno Taquería`,
ContactName: `Antonio Moreno`,
ContactTitle: `Owner`,
Address: `Mataderos 2312`,
City: `México D.F.`,
Region: `South`,
PostalCode: `05023`,
Country: `Mexico`,
Phone: `(5) 555-3932`,
Fax: `(5) 555-3745`
}));
this.push(new CustomersDataItem(
{
ID: `AROUT`,
CompanyName: `Around the Horn`,
ContactName: `Thomas Hardy`,
ContactTitle: `Sales Representative`,
Address: `120 Hanover Sq.`,
City: `London`,
Region: `East`,
PostalCode: `WA1 1DP`,
Country: `UK`,
Phone: `(171) 555-7788`,
Fax: `(171) 555-6750`
}));
this.push(new CustomersDataItem(
{
ID: `BERGS`,
CompanyName: `Berglunds snabbköp`,
ContactName: `Christina Berglund`,
ContactTitle: `Order Administrator`,
Address: `Berguvsvägen 8`,
City: `Luleå`,
Region: `South`,
PostalCode: `S-958 22`,
Country: `Sweden`,
Phone: `0921-12 34 65`,
Fax: `0921-12 34 67`
}));
this.push(new CustomersDataItem(
{
ID: `BLAUS`,
CompanyName: `Blauer See Delikatessen`,
ContactName: `Hanna Moos`,
ContactTitle: `Sales Representative`,
Address: `Forsterstr. 57`,
City: `Mannheim`,
Region: `East`,
PostalCode: `68306`,
Country: `Germany`,
Phone: `0621-08460`,
Fax: `0621-08924`
}));
this.push(new CustomersDataItem(
{
ID: `BLONP`,
CompanyName: `Blondesddsl père et fils`,
ContactName: `Frédérique Citeaux`,
ContactTitle: `Marketing Manager`,
Address: `24, place Kléber`,
City: `Strasbourg`,
Region: `East`,
PostalCode: `67000`,
Country: `France`,
Phone: `88.60.15.31`,
Fax: `88.60.15.32`
}));
this.push(new CustomersDataItem(
{
ID: `BOLID`,
CompanyName: `Bólido Comidas preparadas`,
ContactName: `Martín Sommer`,
ContactTitle: `Owner`,
Address: `C/ Araquil, 67`,
City: `Madrid`,
Region: `East`,
PostalCode: `28023`,
Country: `Spain`,
Phone: `(91) 555 22 82`,
Fax: `(91) 555 91 99`
}));
this.push(new CustomersDataItem(
{
ID: `BONAP`,
CompanyName: `Bon app'`,
ContactName: `Laurence Lebihan`,
ContactTitle: `Owner`,
Address: `12, rue des Bouchers`,
City: `Marseille`,
Region: `West`,
PostalCode: `13008`,
Country: `France`,
Phone: `91.24.45.40`,
Fax: `91.24.45.41`
}));
this.push(new CustomersDataItem(
{
ID: `BOTTM`,
CompanyName: `Bottom-Dollar Markets`,
ContactName: `Elizabeth Lincoln`,
ContactTitle: `Accounting Manager`,
Address: `23 Tsawassen Blvd.`,
City: `Tsawassen`,
Region: `BC`,
PostalCode: `T2F 8M4`,
Country: `Canada`,
Phone: `(604) 555-4729`,
Fax: `(604) 555-3745`
}));
this.push(new CustomersDataItem(
{
ID: `BSBEV`,
CompanyName: `B's Beverages`,
ContactName: `Victoria Ashworth`,
ContactTitle: `Sales Representative`,
Address: `Fauntleroy Circus`,
City: `London`,
Region: `South`,
PostalCode: `EC2 5NT`,
Country: `UK`,
Phone: `(171) 555-1212`,
Fax: `(5) 555-3745`
}));
this.push(new CustomersDataItem(
{
ID: `CACTU`,
CompanyName: `Cactus Comidas para llevar`,
ContactName: `Patricio Simpson`,
ContactTitle: `Sales Agent`,
Address: `Cerrito 333`,
City: `Buenos Aires`,
Region: `East`,
PostalCode: `1010`,
Country: `Argentina`,
Phone: `(1) 135-5555`,
Fax: `(1) 135-4892`
}));
this.push(new CustomersDataItem(
{
ID: `CENTC`,
CompanyName: `Centro comercial Moctezuma`,
ContactName: `Francisco Chang`,
ContactTitle: `Marketing Manager`,
Address: `Sierras de Granada 9993`,
City: `México D.F.`,
Region: `South`,
PostalCode: `05022`,
Country: `Mexico`,
Phone: `(5) 555-3392`,
Fax: `(5) 555-7293`
}));
this.push(new CustomersDataItem(
{
ID: `CHOPS`,
CompanyName: `Chop-suey Chinese`,
ContactName: `Yang Wang`,
ContactTitle: `Owner`,
Address: `Hauptstr. 29`,
City: `Bern`,
Region: `East`,
PostalCode: `3012`,
Country: `Switzerland`,
Phone: `0452-076545`,
Fax: `(5) 555-3745`
}));
this.push(new CustomersDataItem(
{
ID: `COMMI`,
CompanyName: `Comércio Mineiro`,
ContactName: `Pedro Afonso`,
ContactTitle: `Sales Associate`,
Address: `Av. dos Lusíadas, 23`,
City: `Sao Paulo`,
Region: `SP`,
PostalCode: `05432-043`,
Country: `Brazil`,
Phone: `(11) 555-7647`,
Fax: `(5) 555-3745`
}));
this.push(new CustomersDataItem(
{
ID: `CONSH`,
CompanyName: `Consolidated Holdings`,
ContactName: `Elizabeth Brown`,
ContactTitle: `Sales Representative`,
Address: `Berkeley Gardens 12 Brewery`,
City: `London`,
Region: `South`,
PostalCode: `WX1 6LT`,
Country: `UK`,
Phone: `(171) 555-2282`,
Fax: `(171) 555-9199`
}));
this.push(new CustomersDataItem(
{
ID: `DRACD`,
CompanyName: `Drachenblut Delikatessen`,
ContactName: `Sven Ottlieb`,
ContactTitle: `Order Administrator`,
Address: `Walserweg 21`,
City: `Aachen`,
Region: `South`,
PostalCode: `52066`,
Country: `Germany`,
Phone: `0241-039123`,
Fax: `0241-059428`
}));
this.push(new CustomersDataItem(
{
ID: `DUMON`,
CompanyName: `Du monde entier`,
ContactName: `Janine Labrune`,
ContactTitle: `Owner`,
Address: `67, rue des Cinquante Otages`,
City: `Nantes`,
Region: `East`,
PostalCode: `44000`,
Country: `France`,
Phone: `40.67.88.88`,
Fax: `40.67.89.89`
}));
this.push(new CustomersDataItem(
{
ID: `EASTC`,
CompanyName: `Eastern Connection`,
ContactName: `Ann Devon`,
ContactTitle: `Sales Agent`,
Address: `35 King George`,
City: `London`,
Region: `East`,
PostalCode: `WX3 6FW`,
Country: `UK`,
Phone: `(171) 555-0297`,
Fax: `(171) 555-3373`
}));
this.push(new CustomersDataItem(
{
ID: `ERNSH`,
CompanyName: `Ernst Handel`,
ContactName: `Roland Mendel`,
ContactTitle: `Sales Manager`,
Address: `Kirchgasse 6`,
City: `Graz`,
Region: `South`,
PostalCode: `8010`,
Country: `Austria`,
Phone: `7675-3425`,
Fax: `7675-3426`
}));
this.push(new CustomersDataItem(
{
ID: `FAMIA`,
CompanyName: `Familia Arquibaldo`,
ContactName: `Aria Cruz`,
ContactTitle: `Marketing Assistant`,
Address: `Rua Orós, 92`,
City: `Sao Paulo`,
Region: `SP`,
PostalCode: `05442-030`,
Country: `Brazil`,
Phone: `(11) 555-9857`,
Fax: `(5) 555-3745`
}));
this.push(new CustomersDataItem(
{
ID: `FISSA`,
CompanyName: `FISSA Fabrica Inter. Salchichas S.A.`,
ContactName: `Diego Roel`,
ContactTitle: `Accounting Manager`,
Address: `C/ Moralzarzal, 86`,
City: `Madrid`,
Region: `East`,
PostalCode: `28034`,
Country: `Spain`,
Phone: `(91) 555 94 44`,
Fax: `(91) 555 55 93`
}));
this.push(new CustomersDataItem(
{
ID: `FOLIG`,
CompanyName: `Folies gourmandes`,
ContactName: `Martine Rancé`,
ContactTitle: `Assistant Sales Agent`,
Address: `184, chaussée de Tournai`,
City: `Lille`,
Region: `South`,
PostalCode: `59000`,
Country: `France`,
Phone: `20.16.10.16`,
Fax: `20.16.10.17`
}));
this.push(new CustomersDataItem(
{
ID: `FOLKO`,
CompanyName: `Folk och fä HB`,
ContactName: `Maria Larsson`,
ContactTitle: `Owner`,
Address: `Åkergatan 24`,
City: `Bräcke`,
Region: `East`,
PostalCode: `S-844 67`,
Country: `Sweden`,
Phone: `0695-34 67 21`,
Fax: `0695 33-4455`
}));
this.push(new CustomersDataItem(
{
ID: `FRANK`,
CompanyName: `Frankenversand`,
ContactName: `Peter Franken`,
ContactTitle: `Marketing Manager`,
Address: `Berliner Platz 43`,
City: `München`,
Region: `East`,
PostalCode: `80805`,
Country: `Germany`,
Phone: `089-0877310`,
Fax: `089-0877451`
}));
this.push(new CustomersDataItem(
{
ID: `FRANR`,
CompanyName: `France restauration`,
ContactName: `Carine Schmitt`,
ContactTitle: `Marketing Manager`,
Address: `54, rue Royale`,
City: `Nantes`,
Region: `South`,
PostalCode: `44000`,
Country: `France`,
Phone: `40.32.21.21`,
Fax: `40.32.21.20`
}));
this.push(new CustomersDataItem(
{
ID: `FRANS`,
CompanyName: `Franchi S.p.A.`,
ContactName: `Paolo Accorti`,
ContactTitle: `Sales Representative`,
Address: `Via Monte Bianco 34`,
City: `Torino`,
Region: `East`,
PostalCode: `10100`,
Country: `Italy`,
Phone: `011-4988260`,
Fax: `011-4988261`
}));
}
}
tsimport React, { useEffect, useRef, useState } from 'react';
import ReactDOM from 'react-dom/client';
import {
IgrActionStrip,
IgrGrid,
IgrColumn,
IgrGridPinningActions,
IgrGridToolbar,
IgrGridToolbarActions,
IgrGridToolbarHiding,
IgrGridToolbarPinning,
IgrPaginator,
IgrGridState,
IgrGridStateOptions
} from "@infragistics/igniteui-react-grids";
import { IgrButton, IgrCheckbox, IgrCheckboxChangeEventArgs, IgrIcon, registerIconFromText } from "@infragistics/igniteui-react";
import { CustomersData } from './CustomersData';
import "@infragistics/igniteui-react-grids/grids/themes/light/bootstrap.css";
import './index.css';
const restoreIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M480-120q-138 0-240.5-91.5T122-440h82q14 104 92.5 172T480-200q117 0 198.5-81.5T760-480q0-117-81.5-198.5T480-760q-69 0-129 32t-101 88h110v80H120v-240h80v94q51-64 124.5-99T480-840q75 0 140.5 28.5t114 77q48.5 48.5 77 114T840-480q0 75-28.5 140.5t-77 114q-48.5 48.5-114 77T480-120Zm112-192L440-464v-216h80v184l128 128-56 56Z"/></svg>';
const saveIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7l-4-4zm2 16H5V5h11.17L19 7.83V19zm-7-7c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3zM6 6h9v4H6z"/></svg>';
const clearIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/></svg>';
const forwardIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M647-440H160v-80h487L423-744l57-56 320 320-320 320-57-56 224-224Z"/></svg>';
const deleteIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z"/></svg>';
const refreshIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M480-160q-134 0-227-93t-93-227q0-134 93-227t227-93q69 0 132 28.5T720-690v-110h80v280H520v-80h168q-32-56-87.5-88T480-720q-100 0-170 70t-70 170q0 100 70 170t170 70q77 0 139-44t87-116h84q-28 106-114 173t-196 67Z"/></svg>';
export default function App() {
const gridData = new CustomersData();
const stateKey = "grid-state";
const [allOptions, setAllOptions] = useState(true);
const [options, setOption] = useState<IgrGridStateOptions>({
cellSelection: true,
rowSelection: true,
filtering: true,
advancedFiltering: true,
paging: true,
sorting: true,
groupBy: true,
columns: true,
expansion: true,
rowPinning: true,
columnSelection: true
});
const [page, setPage] = useState<number>(0);
const [perPage, setPerPage] = useState<number>(15);
const [totalRecords, setTotalRecords] = useState<number>(gridData.length);
let grid: IgrGrid;
const gridRef = (ref: IgrGrid) => {
grid = ref;
};
const gridStateRef = useRef<IgrGridState>(null);
useEffect(() => {
registerIconFromText("restore", restoreIcon, "material");
registerIconFromText("save", saveIcon, "material");
registerIconFromText("clear", clearIcon, "material");
registerIconFromText("forward", forwardIcon, "material");
registerIconFromText("delete", deleteIcon, "material");
registerIconFromText("refresh", refreshIcon, "material");
restoreGridState();
window.addEventListener("beforeunload", saveGridState);
return () => {
window.removeEventListener("beforeunload", saveGridState);
};
}, []);
const saveGridState = () => {
const state = gridStateRef.current.getStateAsString([]);
window.localStorage.setItem(stateKey, state);
}
const restoreGridState = () => {
const state = window.localStorage.getItem(stateKey);
if (state) {
gridStateRef.current.applyStateFromString(state, []);
}
}
const resetGridState = () => {
setPage(0);
setPerPage(15);
setTotalRecords(gridData.length);
grid.clearFilter();
grid.sortingExpressions = [];
grid.groupingExpressions = [];
grid.deselectAllColumns();
grid.deselectAllRows();
grid.clearCellSelection();
}
const onChange = (e: IgrCheckboxChangeEventArgs) => {
const s = e.target as IgrCheckbox;
if (s.name === 'allFeatures') {
const isChecked = e.detail.checked;
setAllOptions(isChecked);
setOption({
cellSelection: isChecked,
rowSelection: isChecked,
filtering: isChecked,
advancedFiltering: isChecked,
paging: isChecked,
sorting: isChecked,
groupBy: isChecked,
columns: isChecked,
expansion: isChecked,
rowPinning: isChecked,
columnSelection: isChecked
});
} else {
const newOptions = { ...options };
newOptions[s.name as keyof typeof newOptions] = e.detail.checked;
setOption(newOptions);
}
}
const leavePage = () => {
saveGridState();
window.location.replace("./grids/grid/state-persistence-about");
}
const clearStorage = () => {
window.localStorage.removeItem(stateKey);
}
const reloadPage = () => {
window.location.reload();
}
return (
<div className="vertical sampleContainer">
<div className="container horizontal">
<IgrButton onClick={restoreGridState}>
<IgrIcon name="restore" collection="material"></IgrIcon>
<span>Restore</span>
</IgrButton>
<IgrButton onClick={saveGridState}>
<IgrIcon name="save" collection="material"></IgrIcon>
<span>Save</span>
</IgrButton>
<IgrButton onClick={resetGridState}>
<IgrIcon name="clear" collection="material"></IgrIcon>
<span>Reset</span>
</IgrButton>
<IgrButton onClick={leavePage}>
<IgrIcon name="forward" collection="material"></IgrIcon>
<span>Leave</span>
</IgrButton>
<IgrButton onClick={clearStorage}>
<IgrIcon name="delete" collection="material"></IgrIcon>
<span>Clear</span>
</IgrButton>
<IgrButton onClick={reloadPage}>
<IgrIcon name="refresh" collection="material"></IgrIcon>
<span>Reload</span>
</IgrButton>
</div>
<div className="container horizontal">
<ul>
<li>Clicking the SAVE button or leaving the page <a id="leaveLink" href="./grids/grid/state-persistence-about"><strong>here</strong></a> will save grid state to localStorage.</li>
<li>Use the control buttons to SAVE / RESTORE / RESET / DELETE / grid state or LEAVE the page.</li>
<li>Select/Deselect checkboxes to control saving / restoring feature state.</li>
</ul>
</div>
<div className="container horizontal">
<IgrCheckbox name="allFeatures" onChange={onChange} checked={allOptions}><span>All Features</span></IgrCheckbox>
<IgrCheckbox name="advancedFiltering" onChange={onChange} checked={options.advancedFiltering}><span>Adv. Filtering</span></IgrCheckbox>
<IgrCheckbox name="cellSelection" onChange={onChange} checked={options.cellSelection}><span>Cell Selection</span></IgrCheckbox>
<IgrCheckbox name="columns" onChange={onChange} checked={options.columns}><span>Columns</span></IgrCheckbox>
<IgrCheckbox name="columnSelection" onChange={onChange} checked={options.columnSelection}><span>Col Selection</span></IgrCheckbox>
<IgrCheckbox name="expansion" onChange={onChange} checked={options.expansion}><span>Expansion</span></IgrCheckbox>
<IgrCheckbox name="filtering" onChange={onChange} checked={options.filtering}><span>Filtering </span></IgrCheckbox>
<IgrCheckbox name="paging" onChange={onChange} checked={options.paging}><span>Paging</span></IgrCheckbox>
<IgrCheckbox name="rowPinning" onChange={onChange} checked={options.rowPinning}><span>Row Pinning</span></IgrCheckbox>
<IgrCheckbox name="rowSelection" onChange={onChange} checked={options.rowSelection}><span>Row Selection</span></IgrCheckbox>
<IgrCheckbox name="sorting" onChange={onChange} checked={options.sorting}><span>Sorting</span></IgrCheckbox>
<IgrCheckbox name="groupBy" onChange={onChange} checked={options.groupBy}><span>Group By</span></IgrCheckbox>
</div>
<IgrGrid ref={gridRef} data={gridData} primaryKey="ID" width="95%" height="500px" autoGenerate={false} moving={true} allowFiltering={true}
allowAdvancedFiltering={true} filterMode="excelStyleFilter" columnSelection="multiple" rowSelection="multiple">
<IgrGridState ref={gridStateRef}></IgrGridState>
<IgrGridToolbar>
<IgrGridToolbarActions>
<IgrGridToolbarHiding></IgrGridToolbarHiding>
<IgrGridToolbarPinning></IgrGridToolbarPinning>
</IgrGridToolbarActions>
</IgrGridToolbar>
<IgrActionStrip>
<IgrGridPinningActions></IgrGridPinningActions>
</IgrActionStrip>
<IgrPaginator
page={page}
perPage={perPage}
totalRecords={totalRecords}
onPageChange={(ev) => setPage(ev.detail)}
onPerPageChange={(ev) => setPerPage(ev.detail)}>
</IgrPaginator>
<IgrColumn field="ID" width="100px" sortable={true} filterable={true} pinned={true}></IgrColumn>
<IgrColumn field="ContactName" header="Contact Name" minWidth="200px" sortable={true} filterable={true} pinned={true}></IgrColumn>
<IgrColumn field="ContactTitle" header="Contact Title" minWidth="200px" sortable={true} filterable={true} groupable={true}></IgrColumn>
<IgrColumn field="CompanyName" header="Company Name" minWidth="200px" sortable={true} filterable={true} groupable={true}></IgrColumn>
<IgrColumn field="Country" minWidth="200px" sortable={true} filterable={true} groupable={true}></IgrColumn>
<IgrColumn field="City" minWidth="200px" sortable={true} filterable={true} groupable={true}></IgrColumn>
<IgrColumn field="Address" minWidth="200px" sortable={true} filterable={true} groupable={true}></IgrColumn>
<IgrColumn field="PostalCode" header="Postal Code" minWidth="200px" sortable={true} filterable={true} groupable={true}></IgrColumn>
</IgrGrid>
</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 */
.horizontal {
gap: 10px;
flex-basis: fit-content;
flex-wrap: wrap;
}
.sampleContainer {
padding: 0.5rem
}
css
이 샘플이 마음에 드시나요? Ignite UI for React 전체에 액세스하고 몇 분 만에 나만의 앱을 빌드하기 시작하세요. 무료로 다운로드하세요.
제한 사항
getStateAsString
메서드는 JSON.stringify() 메서드를 사용하여 원본 객체를 JSON 문자열로 변환합니다. JSON.stringify()는 함수를 지원하지 않으므로IgrGridState
구성 요소가 열,,,,cellClasses
sortStrategy
,filters
summaries
및bodyTemplate
headerTemplate
cellStyles
속성을 무시합니다.formatter