Web Components Hierarchical Grid の Ignite UI for Web Components 行選択機能を使用すると、ユーザーは 1 つまたは複数のデータ行を対話的に選択、ハイライト表示、または選択解除できます。IgcHierarchicalGridComponent 内に使用可能な選択モードがいくつかあります。
<!DOCTYPE html><html><head><title>Sample | Ignite UI | Web Components | infragistics</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" /><linkrel="stylesheet"href="/src/index.css"type="text/css" /></head><body><divid="root"><divclass="container sample ig-typography"><divclass="options vertical"><igc-property-editor-paneldescription-type="WebHierarchicalGrid"is-wrapping-enabled="true"is-horizontal="true"name="propertyEditorPanel1"id="propertyEditorPanel1"><igc-property-editor-property-descriptionname="selectionType"id="selectionType"property-path="RowSelection"></igc-property-editor-property-description><igc-property-editor-property-descriptionname="hideRowSelectors"id="hideRowSelectors"property-path="HideRowSelectors"></igc-property-editor-property-description></igc-property-editor-panel></div><divclass="container fill"><igc-hierarchical-gridauto-generate="false"name="hierarchicalGrid"id="hierarchicalGrid"id="hierarchicalGrid"primary-key="ID"allow-filtering="true"><igc-columnfield="Artist"></igc-column><igc-columnfield="Photo"data-type="image"></igc-column><igc-columnfield="Debut"></igc-column><igc-columnfield="GrammyNominations"header="Grammy Nominations"></igc-column><igc-columnfield="GrammyAwards"header="Grammy Awards"></igc-column><igc-row-islandchild-data-key="Albums"auto-generate="false"><igc-columnfield="Album"></igc-column><igc-columnfield="LaunchDate"header="Launch Date"data-type="date"></igc-column><igc-columnfield="BillboardReview"header="Billboard Review"></igc-column><igc-columnfield="USBillboard200"header="US Billboard 200"></igc-column><igc-row-islandchild-data-key="Songs"auto-generate="false"><igc-columnfield="Number"header="No."></igc-column><igc-columnfield="Title"></igc-column><igc-columnfield="Released"data-type="date"></igc-column><igc-columnfield="Genre"></igc-column></igc-row-island></igc-row-island><igc-row-islandchild-data-key="Tours"auto-generate="false"><igc-columnfield="Tour"></igc-column><igc-columnfield="StartedOn"header="Started on"></igc-column><igc-columnfield="Location"></igc-column><igc-columnfield="Headliner"></igc-column></igc-row-island></igc-hierarchical-grid></div></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
このサンプルが気に入りましたか? 完全な Ignite UI for Web Componentsツールキットにアクセスして、すばやく独自のアプリの作成を開始します。無料でダウンロードできます。
<igc-hierarchical-gridid="grid"primary-key="ProductID"row-selection="Multiple"auto-generate="true"></igc-hierarchical-grid><buttonid='select'>Select 1,2 and 5</button>html
<!DOCTYPE html><html><head><title>Sample | Ignite UI | Web Components | infragistics</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" /><linkrel="stylesheet"href="/src/index.css"type="text/css" /></head><body><divid="root"><divclass="container sample ig-typography"><divclass="container fill"><igc-hierarchical-gridauto-generate="false"name="hierarchicalGrid"id="hierarchicalGrid"id="hierarchicalGrid"primary-key="ID"row-selection="multiple"cell-selection="none"><igc-paginatorname="paginator"id="paginator"></igc-paginator><igc-columnfield="Artist"></igc-column><igc-columnfield="Photo"data-type="image"></igc-column><igc-columnfield="Debut"></igc-column><igc-columnfield="GrammyNominations"header="Grammy Nominations"></igc-column><igc-columnfield="GrammyAwards"header="Grammy Awards"></igc-column><igc-row-islandchild-data-key="Albums"auto-generate="false"><igc-columnfield="Album"></igc-column><igc-columnfield="LaunchDate"header="Launch Date"data-type="date"></igc-column><igc-columnfield="BillboardReview"header="Billboard Review"></igc-column><igc-columnfield="USBillboard200"header="US Billboard 200"></igc-column><igc-row-islandchild-data-key="Songs"auto-generate="false"><igc-columnfield="Number"header="No."></igc-column><igc-columnfield="Title"></igc-column><igc-columnfield="Released"data-type="date"></igc-column><igc-columnfield="Genre"></igc-column></igc-row-island></igc-row-island><igc-row-islandchild-data-key="Tours"auto-generate="false"><igc-columnfield="Tour"></igc-column><igc-columnfield="StartedOn"header="Started on"></igc-column><igc-columnfield="Location"></igc-column><igc-columnfield="Headliner"></igc-column></igc-row-island></igc-hierarchical-grid></div></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
import'igniteui-webcomponents-grids/grids/combined';
import { ComponentRenderer, WebHierarchicalGridDescriptionModule } from'igniteui-webcomponents-core';
import { IgcHierarchicalGridComponent, IgcPaginatorComponent } from'igniteui-webcomponents-grids/grids';
import SingersData from'./SingersData.json';
import { IgcRowSelectionEventArgs } from'igniteui-webcomponents-grids/grids';
import"igniteui-webcomponents-grids/grids/themes/light/bootstrap.css";
import"./index.css";
exportclassSample{
private hierarchicalGrid: IgcHierarchicalGridComponent
private paginator: IgcPaginatorComponent
private _bind: () =>void;
constructor() {
var hierarchicalGrid = this.hierarchicalGrid = document.getElementById('hierarchicalGrid') as IgcHierarchicalGridComponent;
this.webHierarchicalGridRowSelectionConditional = this.webHierarchicalGridRowSelectionConditional.bind(this);
var paginator = this.paginator = document.getElementById('paginator') as IgcPaginatorComponent;
this._bind = () => {
hierarchicalGrid.data = this.singersData;
hierarchicalGrid.addEventListener("rowSelectionChanging", this.webHierarchicalGridRowSelectionConditional);
}
this._bind();
}
private _singersData: any[] = SingersData;
publicgetsingersData(): any[] {
returnthis._singersData;
}
private _componentRenderer: ComponentRenderer = null;
publicgetrenderer(): ComponentRenderer {
if (this._componentRenderer == null) {
this._componentRenderer = new ComponentRenderer();
var context = this._componentRenderer.context;
WebHierarchicalGridDescriptionModule.register(context);
}
returnthis._componentRenderer;
}
public webHierarchicalGridRowSelectionConditional(eventArgs: CustomEvent<IgcRowSelectionEventArgs>): void {
const event = eventArgs.detail;
if (!event.added.length && event.removed.length) {
// ignore de-selectreturn;
}
var grid = this.hierarchicalGrid;
const originalAddedLength = event.added.length;
// only allow selection of items that has grammy award
event.newSelection = event.newSelection.filter((x: any) => x.HasGrammyAward);
// cleanup selection if all conditionally selectable rows are already selectedif (event.newSelection.length
&& !event.newSelection.filter((x: any) => event.oldSelection.indexOf(x) === -1).length
&& originalAddedLength > 1) {
// all selected from header, de-select instead
event.newSelection = [];
}
}
}
new Sample();
ts
<!DOCTYPE html><html><head><title>Sample | Ignite UI | Web Components | infragistics</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" /><linkrel="stylesheet"href="/src/index.css"type="text/css" /></head><body><divid="root"><divclass="container sample ig-typography"><divclass="container fill"><igc-hierarchical-gridauto-generate="false"name="hierarchicalGrid"id="hierarchicalGrid"id="hierarchicalGrid"primary-key="ID"row-selection="multiple"cell-selection="none"><igc-paginatorname="paginator"id="paginator"></igc-paginator><igc-columnfield="Artist"></igc-column><igc-columnfield="Debut"></igc-column><igc-columnfield="GrammyNominations"header="Grammy Nominations"></igc-column><igc-columnfield="GrammyAwards"header="Grammy Awards"></igc-column><igc-row-islandchild-data-key="Albums"auto-generate="false"row-selection="multiple"><igc-columnfield="Album"></igc-column><igc-columnfield="LaunchDate"header="Launch Date"data-type="date"></igc-column><igc-columnfield="BillboardReview"header="Billboard Review"></igc-column><igc-columnfield="USBillboard200"header="US Billboard 200"></igc-column><igc-row-islandchild-data-key="Songs"auto-generate="false"row-selection="multiple"><igc-columnfield="Number"header="No."></igc-column><igc-columnfield="Title"></igc-column><igc-columnfield="Released"data-type="date"></igc-column><igc-columnfield="Genre"></igc-column></igc-row-island></igc-row-island><igc-row-islandchild-data-key="Tours"auto-generate="false"row-selection="multiple"><igc-columnfield="Tour"></igc-column><igc-columnfield="StartedOn"header="Started on"></igc-column><igc-columnfield="Location"></igc-column><igc-columnfield="Headliner"></igc-column></igc-row-island></igc-hierarchical-grid></div></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css