React Hierarchical Grid 選択の概要
React Hierarchical Grid の Ignite UI for React 選択機能を使用すると、単純なマウス操作を使用してデータを簡単に操作および操作できます。使用可能な選択モードは 3 つあります。
rowSelection
プロパティを使用すると、以下を指定できます。
- None (なし)
- Single (単一)
- Multiple Select (複数選択)
React Hierarchical Grid 選択の例
以下のサンプルは、IgrHierarchicalGrid
の 3 種類のセル選択動作を示しています。以下のボタンを使用して、利用可能な各選択モードを有効にします。
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrPropertyEditorPanelModule } from "@infragistics/igniteui-react-layouts";
import { IgrHierarchicalGridModule } from "@infragistics/igniteui-react-grids";
import { IgrPropertyEditorPanel, IgrPropertyEditorPropertyDescription } from "@infragistics/igniteui-react-layouts";
import { IgrHierarchicalGrid, IgrColumn, IgrRowIsland } from "@infragistics/igniteui-react-grids";
import { ComponentRenderer, PropertyEditorPanelDescriptionModule, WebHierarchicalGridDescriptionModule } from "@infragistics/igniteui-react-core";
import SingersData from './SingersData.json';
import { IgrPropertyEditorPropertyDescriptionChangedEventArgs } from "@infragistics/igniteui-react-layouts";
import "@infragistics/igniteui-react-grids/grids/combined";
import "@infragistics/igniteui-react-grids/grids/themes/light/bootstrap.css";
import 'igniteui-webcomponents/themes/light/bootstrap.css';
const mods: any[] = [
IgrPropertyEditorPanelModule,
IgrHierarchicalGridModule
];
mods.forEach((m) => m.register());
export default class Sample extends React.Component<any, any> {
private propertyEditorHierarchicalGrid: IgrPropertyEditorPanel
private propertyEditorHierarchicalGridRef(r: IgrPropertyEditorPanel) {
this.propertyEditorHierarchicalGrid = r;
this.setState({});
}
private cellSelectionEditorHierarchicalGrid: IgrPropertyEditorPropertyDescription
private cellSelectionEditorRowIsland: IgrPropertyEditorPropertyDescription
private hierarchicalGrid: IgrHierarchicalGrid
private hierarchicalGridRef(r: IgrHierarchicalGrid) {
this.hierarchicalGrid = r;
this.setState({});
}
private rowIsland: IgrRowIsland
constructor(props: any) {
super(props);
this.propertyEditorHierarchicalGridRef = this.propertyEditorHierarchicalGridRef.bind(this);
this.webRowIslandCellSelectionChange = this.webRowIslandCellSelectionChange.bind(this);
this.hierarchicalGridRef = this.hierarchicalGridRef.bind(this);
}
public render(): JSX.Element {
return (
<div className="container sample ig-typography">
<div className="options vertical">
<IgrPropertyEditorPanel
ref={this.propertyEditorHierarchicalGridRef}
componentRenderer={this.renderer}
target={this.hierarchicalGrid}
descriptionType="WebHierarchicalGrid"
isHorizontal="true"
isWrappingEnabled="true">
<IgrPropertyEditorPropertyDescription
label="Hierarchical Grid Cell Selection"
propertyPath="CellSelection"
name="CellSelectionEditorHierarchicalGrid"
valueType="EnumValue">
</IgrPropertyEditorPropertyDescription>
<IgrPropertyEditorPropertyDescription
label="Row Island Cell Selection"
propertyPath=""
name="CellSelectionEditorRowIsland"
valueType="EnumValue"
dropDownNames={["None", "Single", "Multiple", "MultipleCascade"]}
dropDownValues={["None", "Single", "Multiple", "MultipleCascade"]}
changed={this.webRowIslandCellSelectionChange}>
</IgrPropertyEditorPropertyDescription>
</IgrPropertyEditorPanel>
</div>
<div className="container fill">
<IgrHierarchicalGrid
autoGenerate={false}
data={this.singersData}
primaryKey="ID"
id="hierarchicalGrid"
ref={this.hierarchicalGridRef}>
<IgrColumn
field="Artist"
header="Artist"
dataType="string">
</IgrColumn>
<IgrColumn
field="HasGrammyAward"
header="Has Grammy Award"
dataType="boolean">
</IgrColumn>
<IgrColumn
field="Debut"
header="Debut"
dataType="number">
</IgrColumn>
<IgrColumn
field="GrammyNominations"
header="Grammy Nominations"
dataType="number"
hasSummary={true}>
</IgrColumn>
<IgrColumn
field="GrammyAwards"
header="Grammy Awards"
dataType="number"
hasSummary={true}>
</IgrColumn>
<IgrRowIsland
childDataKey="Albums"
autoGenerate={false}
name="rowIsland">
<IgrColumn
field="Album"
header="Album"
dataType="string">
</IgrColumn>
<IgrColumn
field="LaunchDate"
header="Launch Date"
dataType="date">
</IgrColumn>
<IgrColumn
field="BillboardReview"
header="Billboard Review"
dataType="string">
</IgrColumn>
<IgrColumn
field="USBillboard200"
header="US Billboard 200"
dataType="string">
</IgrColumn>
</IgrRowIsland>
</IgrHierarchicalGrid>
</div>
</div>
);
}
private _singersData: any[] = SingersData;
public get singersData(): any[] {
return this._singersData;
}
private _componentRenderer: ComponentRenderer = null;
public get renderer(): ComponentRenderer {
if (this._componentRenderer == null) {
this._componentRenderer = new ComponentRenderer();
var context = this._componentRenderer.context;
PropertyEditorPanelDescriptionModule.register(context);
WebHierarchicalGridDescriptionModule.register(context);
}
return this._componentRenderer;
}
public webRowIslandCellSelectionChange(sender: any, args: IgrPropertyEditorPropertyDescriptionChangedEventArgs): void {
this.hierarchicalGrid.contentChildLayoutList[0].cellSelection = args.newValue.toLocaleLowerCase();
}
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Sample/>);
tsx
このサンプルが気に入りましたか? 完全な Ignite UI for Reactツールキットにアクセスして、すばやく独自のアプリの作成を開始します。無料でダウンロードできます。
React Hierarchical Grid 選択のオプション
Ignite UI for React IgrHierarchicalGrid
コンポーネントは、行選択、セル選択、列選択の 3 つの選択モードを提供します。デフォルトでは、IgrHierarchicalGrid
で複数セル選択モードのみが有効になっています。選択モードの変更または有効化は、rowSelection
、cellSelection
または selectable
プロパティを使用します。
React Hierarchical Grid 行選択
プロパティ rowSelection
を使用すると、次のオプションを指定できます。
MultipleCascade
- これはカスケード選択のモードであり、ユーザーがユーザーの操作で選択したレコードの下のツリー内のすべての子が選択されます。このモードでは、親の選択状態はその子の選択状態に完全に依存します。
詳細については、行選択トピックを参照してください。
React Hierarchical Grid セル選択
以下のオプションは、プロパティ cellSelection
で指定できます。
詳細については、セル選択トピックを参照してください。
React Hierarchical Grid 列選択
selectable
プロパティを使用して、IgrColumn
ごとに以下のオプションを指定できます。このプロパティが true または false に設定されている場合、対応する列の選択がそれぞれ有効または無効になります。
以下の 3 つのバリエーションがあります。
- Single selection (単一選択) - 列セルをマウス クリックします。
- Multi column selection (複数列の選択) - Ctrl キーを押しながら列セルをマウス クリックします。
- Range column selection (列の範囲選択) - Shift キーを押しながら + マウス クリック、その間のすべての列が選択されます。
詳細については、列選択トピックを参照してください。
既知の問題と制限
グリッドに primaryKey
が設定されておらず、リモート データ シナリオが有効になっている場合 (ページング、ソート、フィルタリング、スクロール時に、グリッドに表示されるデータを取得するためのリモート サーバーへのリクエストがトリガーされる場合)、データ要求が完了すると、行は次の状態を失います:
API リファレンス
その他のリソース
コミュニティに参加して新しいアイデアをご提案ください。