Angular Tree Grid のセル編集
Ignite UI for Angular Tree Grid コンポーネントは、Angular CRUD 操作のための優れたデータ操作機能と強力な API を提供します。デフォルトで Tree Grid はセル編集 を使用し、デフォルトのセル編集テンプレート によって、列のデータ型に基づいてさまざまなエディターが表示されます。さらに、データ更新アクション用の独自のカスタム テンプレートを定義したり、変更をコミット/破棄したりするためのデフォルトの動作をオーバーライドすることもできます。
Angular Tree Grid セル編集とセル テンプレートの例
import { NgModule } from "@angular/core" ;
import { FormsModule } from "@angular/forms" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { IgxPreventDocumentScrollModule } from "./directives/prevent-scroll.directive" ;
import {
IgxTreeGridModule,
IgxButtonModule,
IgxDialogModule,
IgxInputGroupModule,
IgxCheckboxModule,
IgxDatePickerModule
} from "igniteui-angular" ;
import { TreeGridEditingSampleComponent } from "./tree-grid-editing-sample/tree-grid-editing-sample.component" ;
@NgModule ({
bootstrap : [AppComponent],
declarations : [
AppComponent,
TreeGridEditingSampleComponent
],
imports : [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
IgxPreventDocumentScrollModule,
IgxTreeGridModule,
IgxButtonModule,
IgxDialogModule,
IgxInputGroupModule,
IgxCheckboxModule,
IgxDatePickerModule
],
providers : [],
entryComponents : [],
schemas : []
})
export class AppModule {}
ts コピー import { Component, OnInit, ViewChild } from '@angular/core' ;
import {
IgxDialogComponent, IgxNumberSummaryOperand, IgxSummaryOperand, IgxSummaryResult, IgxTreeGridComponent
} from 'igniteui-angular' ;
import { generateEmployeeFlatData } from '../data/employees-flat' ;
import { Employee } from './employee' ;
class CustomNumberSummary {
public operate(data?: any []): IgxSummaryResult[] {
const result = new IgxSummaryOperand().operate(data);
result.push({
key : 'Min' ,
label : 'Min' ,
summaryResult : IgxNumberSummaryOperand.min(data)
});
result.push({
key : 'max' ,
label : 'Max' ,
summaryResult : IgxNumberSummaryOperand.max(data)
});
return result;
}
}
@Component ({
selector : 'app-tree-grid-editing-sample' ,
styleUrls : ['./tree-grid-editing-sample.component.scss' ],
templateUrl : './tree-grid-editing-sample.component.html'
})
export class TreeGridEditingSampleComponent implements OnInit {
@ViewChild ('treeGrid' , { static : true }) public treeGrid: IgxTreeGridComponent;
@ViewChild ('dialogAdd' , { read : IgxDialogComponent, static : true }) public dialog: IgxDialogComponent;
public data: any [];
public numberSummaries = CustomNumberSummary;
public employee: Employee;
private nextRow: number ;
constructor ( ) {
}
public ngOnInit(): void {
this .data = generateEmployeeFlatData();
this .employee = new Employee();
this .nextRow = this .data.length + 1 ;
}
public openDialog (parentID ) {
this .employee.ParentID = parentID;
this .dialog.open();
}
public addRow ( ) {
this .employee.ID = this .nextRow++;
if (this .employee.ParentID === -1 ) {
this .treeGrid.addRow(this .employee);
} else {
this .treeGrid.addRow(this .employee, this .employee.ParentID);
}
this .cancel();
}
public cancel ( ) {
this .dialog.close();
this .employee = new Employee();
}
public deleteRow (id ) {
this .treeGrid.deleteRow(id);
}
}
ts コピー <div class ="grid__wrapper" >
<button igxButton ="outlined" class ="addRootBtn" (click )="openDialog(-1)" >
<igx-icon > person_add</igx-icon >
<span > Add Root Employee</span >
</button >
<igx-tree-grid [igxPreventDocumentScroll ]="true" #treeGrid [data ]="data" primaryKey ="ID" foreignKey ="ParentID" [autoGenerate ]="false" displayDensity ="comfortable"
width ="100%" height ="800px" [allowFiltering ]="true" >
<igx-paginator [perPage ]="10" > </igx-paginator >
<igx-column [field ]="'Name'" dataType ="string" [editable ]="true" [hasSummary ]="true" > </igx-column >
<igx-column [field ]="'Title'" dataType ="string" [editable ]="true" [hasSummary ]="true" > </igx-column >
<igx-column [field ]="'Age'" dataType ="number" [editable ]="true" [hasSummary ]="true" [summaries ]="numberSummaries" > </igx-column >
<igx-column [field ]="'HireDate'" dataType ="date" [editable ]="true" [hasSummary ]="true" > </igx-column >
<igx-column [field ]="'OnPTO'" dataType ="boolean" [editable ]="true" [hasSummary ]="true" width ="130px" >
<ng-template igxCell let-cell ="cell" let-val >
<igx-icon [style.color ]="cell.row.data.OnPTO? 'red': 'green'" > account_circle</igx-icon >
</ng-template >
</igx-column >
<igx-column [filterable ]="false" width ="130px" >
<ng-template igxCell let-cell ="cell" >
<div class ="buttonsArea" >
<button igxButton ="icon" (click )="openDialog(cell.row.key)" class ="emplBtn" >
<igx-icon > person_add</igx-icon >
</button >
<button igxButton ="icon" (click )="deleteRow(cell.row.key)" class ="emplBtn" >
<igx-icon > delete</igx-icon >
</button >
</div >
</ng-template >
</igx-column >
</igx-tree-grid >
<igx-dialog #dialogAdd title ="New Employee" [rightButtonLabel ]="'Add'" [leftButtonLabel ]="'Cancel'"
(leftButtonSelect )="cancel()" (rightButtonSelect )="addRow()" >
<div class ="dialogNewRecord" >
<igx-input-group >
<label igxLabel for ="employeeName" > Employee Name</label >
<input igxInput id ="employeeName" type ="text" [(ngModel )]="employee.Name" />
</igx-input-group >
<igx-input-group >
<label igxLabel for ="employeeTitle" > Title</label >
<input igxInput id ="employeeTitle" type ="text" [(ngModel )]="employee.Title" />
</igx-input-group >
<igx-input-group >
<label igxLabel for ="employeeAge" > Age</label >
<input igxInput id ="employeeAge" type ="number" [(ngModel )]="employee.Age" />
</igx-input-group >
<igx-date-picker class ="datePicker" id ="employeeHireDate" [(ngModel )]="employee.HireDate" mode ="dialog" >
<label igxLabel > Hire Date</label > </igx-date-picker >
<igx-checkbox id ="onPTO" [(ngModel )]="employee.OnPTO" > On PTO</igx-checkbox >
</div >
</igx-dialog >
</div >
html コピー .grid__wrapper {
margin : 20px ;
}
.addRootBtn {
display : flex;
align-items : center;
margin-bottom : 10px ;
color : black;
&:hover {
background-color : rgba(0 , 0 , 0 , 0.1 )
}
igx-icon {
margin-right: 5px ;
}
}
.buttonsArea {
margin : auto;
}
.emplBtn {
margin-right : 5px ;
}
.igx-input-group {
margin-bottom : 10px ;
padding : 5px ;
}
.igx-checkbox {
margin-bottom : 10px ;
padding : 5px ;
}
.datePicker {
padding : 5px ;
margin-bottom : 10px ;
}
scss コピー
このサンプルが気に入りましたか? 完全な Ignite UI for Angularツールキットにアクセスして、すばやく独自のアプリの作成を開始します。無料でダウンロードできます。
任意のタイプのエディター コンポーネントで igxCellEditor
を使用すると、キーボード ナビゲーション フローが中断されます。同じことが、編集モードに入るカスタム セルの直接編集にも当てはまります。これは、追加したエディター コンポーネント (igxSelect
、igxCombo
など) ではなく、セル要素にフォーカスが残るためです。これが、igxFocus
ディレクティブを利用する必要がある理由です。これにより、フォーカスがセル内コンポーネントに直接移動し、セル/行の流暢な編集フロー
が維持されます。
セルの編集
UI を介した編集
編集可能なセルがフォーカスされたときに以下のいずれかの方法で特定のセルを編集モードにすることができます。
ダブルクリック;
シングル クリック - 以前選択したセルが編集モードで現在選択したセルが編集可能な場合のみ、シングル クリックで編集モードに入ります。以前選択したセルが編集モードではない場合、編集モードに入らずにシングル クリックでセルを選択します。
Enter
キーの押下;
F2
キーの押下;
変更をコミットしない場合 も以下の方法で編集モードを終了できます。
Escape
キーの押下;
ソート 、フィルターリング 、検索 、非表示 操作の実行時。
変更をコミット しない場合も以下の方法で編集モードを終了できます。
Enter
キーの押下;
F2
キーの押下;
Tab
キーの押下;
他のセルをシングル クリック - Tree Grid で他のセルをクリックしたときに変更がサブミットされます。
その他の操作 (ページング、サイズ変更、ピン固定、移動など) は、編集モードを終了して変更を送信します。
セルは、垂直/水平方向へのスクロールや Tree Grid 以外をクリックした場合も編集モードのままです。セル編集と行編集両方で有効です。
API を介した編集
プライマリキーが定義されている場合のみ IgxTreeGrid API でもセル値を変更することができます。
public updateCell ( ) {
this .treeGrid.updateCell(newValue, rowID, 'Age' );
}
typescript
セルを更新するその他の方法として IgxGridCell
の update
メソッドで直接更新する方法があります。
public updateCell ( ) {
const cell = this .treeGrid.getCellByColumn(rowIndex, 'Age' );
cell.update(9999 );
}
typescript
セル編集テンプレート
デフォルトのセル編集テンプレートの詳細については、編集トピック を参照してください。
セルが編集モードのときに適用されるカスタム テンプレートを提供する場合は、igxCellEditor
ディレクティブ を使用できます。これを行うには、igxCellEditor
ディレクティブでマークされた ng-template
を渡し、カスタム コントロールを cell.editValue
に適切にバインドする必要があります:
<igx-column field ="class" header ="Class" [editable ]="true" >
<ng-template igxCellEditor let-cell ="cell" let-value >
<igx-select class ="cell-select" [(ngModel )]="cell.editValue" [igxFocus ]="true" >
<igx-select-item *ngFor ="let class of classes" [value ]="class" >
{{ class }}
</igx-select-item >
</igx-select >
</ng-template >
</igx-column >
html
このコードは、Race
、Class
、および Alignment
列のセルに IgxSelectComponent
を実装する以下のサンプルで使用されています。
import { NgModule } from "@angular/core" ;
import { FormsModule } from "@angular/forms" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { IgxPreventDocumentScrollModule } from "./directives/prevent-scroll.directive" ;
import {
IgxGridModule,
IgxSelectModule
} from "igniteui-angular" ;
import { GridSelectComponent } from "./grid/grid-select/grid-select-sample.component" ;
@NgModule ({
bootstrap : [AppComponent],
declarations : [
AppComponent,
GridSelectComponent
],
imports : [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
IgxPreventDocumentScrollModule,
IgxGridModule,
IgxSelectModule
],
providers : [],
entryComponents : [],
schemas : []
})
export class AppModule {}
ts コピー import { Character } from './characters' ;
import { Component, OnInit, ViewChild } from '@angular/core' ;
import { IgxGridComponent } from 'igniteui-angular' ;
import { DATA, ALIGNMENTS, RACES, CLASSES } from './data' ;
@Component ({
selector : 'app-grid-select-sample' ,
styleUrls : ['./grid-select-sample.component.scss' ],
templateUrl : './grid-select-sample.component.html'
})
export class GridSelectComponent implements OnInit {
@ViewChild ('grid1' , { read : IgxGridComponent, static : true })
public grid1: IgxGridComponent;
public data;
public alignments;
public races;
public classes;
public character;
public generateRandomData (data ) {
return data.map((e ) => {
const indexAlignments = Math .floor(Math .random() * ALIGNMENTS.length);
e.alignment = ALIGNMENTS[indexAlignments];
const indexRaces = Math .floor(Math .random() * RACES.length);
e.race = RACES[indexRaces];
const indexClasses = Math .floor(Math .random() * CLASSES.length);
e.class = CLASSES[indexClasses];
return e;
});
}
public ngOnInit ( ) {
this .data = this .generateRandomData(DATA);
this .character = new Character();
this .alignments = ALIGNMENTS;
this .races = RACES;
this .classes = CLASSES;
}
}
ts コピー <igx-grid #grid1 [data ]="data" [primaryKey ]="'name'" height ="600px" >
<igx-column field ="name" header ="Character name" [editable ]="true" >
</igx-column >
<igx-column field ="race" header ="Race" [editable ]="true" >
<ng-template igxCellEditor let-cell ="cell" let-value >
<igx-select class ="cell-select" [(ngModel )]="cell.editValue" [igxFocus ]="true" >
<igx-select-item *ngFor ="let race of races" [value ]="race" >
{{ race }}
</igx-select-item >
</igx-select >
</ng-template >
</igx-column >
<igx-column field ="class" header ="Class" [editable ]="true" >
<ng-template igxCellEditor let-cell ="cell" let-value >
<igx-select class ="cell-select" [(ngModel )]="cell.editValue" [igxFocus ]="true" >
<igx-select-item *ngFor ="let class of classes" [value ]="class" >
{{ class }}
</igx-select-item >
</igx-select >
</ng-template >
</igx-column >
<igx-column field ="age" header ="Age" [dataType ]="'number'" [editable ]="true" width ="10%" >
</igx-column >
<igx-column field ="alignment" header ="Alignment" [editable ]="true" >
<ng-template igxCellEditor let-cell ="cell" let-value >
<igx-select class ="cell-select" [(ngModel )]="cell.editValue" [igxFocus ]="true" >
<igx-select-item *ngFor ="let alignment of alignments" [value ]="alignment" >
{{ alignment }}
</igx-select-item >
</igx-select >
</ng-template >
</igx-column >
</igx-grid >
html コピー :host {
display : block;
padding : 16px ;
}
.cell-select {
width : 100% ;
height : 100% ;
}
scss コピー
セルテンプレート igxCell
は、編集モード外での列のセルの表示方法を制御します。
igxCellEditor
セル編集テンプレート ディレクティブは、編集モードでの列のセルの表示方法を処理し、編集されたセルの編集値を制御します。
任意のタイプのエディター コンポーネントで igxCellEditor
を使用すると、キーボード ナビゲーション フローが中断されます。同じことが、編集モードに入るカスタム セルの直接編集にも当てはまります。これは、追加したエディター コンポーネント (igxSelect
、igxCombo
など) ではなく、セル要素にフォーカスが残るためです。これが、igxFocus
ディレクティブを利用する必要がある理由です。これにより、フォーカスがセル内コンポーネントに直接移動し、セル/行の 流暢な編集フロー
が維持されます。
列とそのテンプレートの構成方法の詳細については、グリッド列構成 のドキュメントを参照してください。
CRUD 操作
CRUD 操作 を実行した場合、filtering 、sorting 、grouping などのパイプが再適用されるため、ビューが自動的に更新されることに注意してください。
IgxTreeGridComponent
は基本的な CRUD 操作のための簡易な API を提供します。
新しいレコードの追加
Tree Grid コンポーネントは、提供したデータをデータ ソースに追加する addRow
メソッドを公開します。
public addNewChildRow ( ) {
const record = this .getNewRecord();
this .treeGrid.addRow(record, 1 );
}
typescript
データを Tree Grid で更新
Tree Grid のデータ更新は、グリッドでプライマリキーが定義されている場合のみ updateRow
と updateCell
メソッドで行うことができます。セルと行の値またはそのいずれかを各 update
メソッドで直接更新できます。
this .treeGrid.updateRow(newData, this .selectedCell.cellID.rowID);
this .treeGrid.updateCell(newData, this .selectedCell.cellID.rowID, this .selectedCell.column.field);
this .selectedCell.update(newData);
const row = this .treeGrid.getRowByKey(rowID);
row.update(newData);
typescript
Tree Grid からデータを削除
deleteRow()
メソッドは、プライマリキーが定義されている場合に指定した行のみを削除することに注意してください。
this .treeGrid.deleteRow(this .selectedCell.cellID.rowID);
const row = this .treeGrid.getRowByIndex(rowIndex);
row.delete();
typescript
igx-tree-grid に関係なく、ボタンのクリックなどのユーザー インタラクションに関連付けできます。
<button igxButton igxRipple (click )="deleteRow($event)" > Delete Row</button >
html
編集イベントでのセル検証
グリッドの編集イベントを使用して、ユーザーがグリッドを操作する方法を変更できます。
この例では、cellEdit
イベントにバインドすることにより、入力されたデータに基づいてセルを検証します。セルの新しい値が事前定義された基準を満たしていない場合、イベントをキャンセルすることでデータソースに到達しないようにします (event.cancel = true
)。また、IgxToast
を使用してカスタム エラーメッセージを表示します。
最初に必要なことは、グリッドのイベントにバインドすることです。
<igx-tree-grid (cellEdit )="handleCellEdit($event)"
... >
...
</igx-tree-grid >
html
cellEdit
は、セルの値がコミットされる直前に発生します。handleCellEdit
の定義では、アクションを実行する前に特定の列を確認する必要があります。
export class MyTreeGridEventsComponent {
public handleCellEdit(event: IGridEditEventArgs): void {
const column = event.column;
if (column.field === 'Age' ) {
if (event.newValue < 18 ) {
event.cancel = true ;
this .toast.message = 'Employees must be at least 18 years old!' ;
this .toast.open();
}
} else if (column.field === 'HireDate' ) {
if (event.newValue > new Date ().getTime()) {
event.cancel = true ;
this .toast.message = 'The employee hire date must be in the past!' ;
this .toast.open();
}
}
}
}
typescript
ここでは、2 つの列を検証しています。ユーザーが従業員の年齢 (18歳未満) または雇用日 (将来の日付) に無効な値を設定しようとすると、編集がキャンセルされ (値は送信されません)、エラー メッセージ付きのトースターが表示されます。
以下は、上記の検証が igx-tree-grid
に適用された結果のデモです。
import { NgModule } from "@angular/core" ;
import { FormsModule } from "@angular/forms" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { IgxPreventDocumentScrollModule } from "./directives/prevent-scroll.directive" ;
import { TreeGridEditingEventsComponent } from "./tree-grid/tree-grid-editing-events/tree-grid-editing-events.component" ;
import {
IgxTreeGridModule,
IgxToastModule
} from "igniteui-angular" ;
@NgModule ({
bootstrap : [AppComponent],
declarations : [
AppComponent,
TreeGridEditingEventsComponent
],
imports : [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
IgxPreventDocumentScrollModule,
IgxTreeGridModule,
IgxToastModule
],
providers : [],
entryComponents : [],
schemas : []
})
export class AppModule {}
ts コピー import { Component, OnInit, ViewChild } from '@angular/core' ;
import { IGridEditEventArgs, IgxToastComponent, VerticalAlignment } from 'igniteui-angular' ;
import { generateEmployeeFlatData, IEmployee } from '../data/employees-flat' ;
@Component ({
selector : 'app-tree-grid-editing-events' ,
templateUrl : 'tree-grid-editing-events.component.html' ,
styleUrls : ['tree-grid-editing-events.component.scss' ]
})
export class TreeGridEditingEventsComponent implements OnInit {
@ViewChild (IgxToastComponent, { read : IgxToastComponent, static : true })
public toast: IgxToastComponent;
public data: IEmployee[] = [];
public ngOnInit ( ) {
this .data = generateEmployeeFlatData();
this .toast.positionSettings.verticalDirection = VerticalAlignment.Middle;
}
public handleEdit (event: IGridEditEventArgs ) {
const column = event.column;
if (column.field === 'Age' ) {
if (event.newValue < 18 ) {
event.cancel = true ;
this .toast.open('Employees must be at least 18 years old!' );
}
} else if (column.field === 'HireDate' ) {
if (event.newValue > new Date ().getTime()) {
event.cancel = true ;
this .toast.open('The employee hire date must be in the past!' );
}
}
}
}
ts コピー <h4 > Current Employees</h4 >
<igx-tree-grid [igxPreventDocumentScroll ]="true" #treeGrid [data ]="data" primaryKey ="ID" foreignKey ="ParentID" width ="100%"
height ="500px" (cellEdit )="handleEdit($event)" >
<igx-column field ="Name" dataType ="string" > </igx-column >
<igx-column field ="Title" dataType ="string" > </igx-column >
<igx-column field ="Age" dataType ="number" [editable ]="true" > </igx-column >
<igx-column field ="HireDate" dataType ="date" [editable ]="true" > </igx-column >
</igx-tree-grid >
<igx-toast > </igx-toast >
html コピー :host {
display : block;
padding : 16px ;
h4 {
margin : 8px ;
}
}
scss コピー
スタイル設定
IgxTreeGrid で Ignite UI for Angular テーマ ライブラリ
を使用してセルのスタイルを設定できます。グリッドの grid-theme
は、ユーザーがグリッドのさまざまな側面をスタイル設定できる広範なプロパティを公開します。
以下の手順では、編集モードでグリッドのセルのスタイルを設定する方法と、それらのスタイルの範囲を設定する方法について説明します。
Ignite UI テーマ ライブラリ
を使用するには、まずグローバル スタイルでテーマ index
ファイルをインポートする必要があります。
スタイル ライブラリのインポート
@use "igniteui-angular/theming" as *;
scss
以上で Ignite UI for Angular テーマ エンジンによって公開されているすべての機能を使用できます。
パレットの定義
インデックス ファイルをインポート後、カスタム パレットを作成します。好きな 3 つの色を定義し、それらを使用して palette
でパレットを作成しましょう。
$white : #fff ;
$blue : #4567bb ;
$gray : #efefef ;
$color-palette : palette(
$primary : $white ,
$secondary : $blue ,
$surface : $gray
);
scss
テーマの定義
これで、パレットを使用してテーマを定義できます。セルは grid-theme
によってスタイル設定されているため、それを使用して IgxTreeGrid のテーマを生成できます。
$custom-grid-theme : grid-theme(
$cell-editing-background : $blue ,
$cell-edited-value-color : $white ,
$cell-active-border-color : $white ,
$edit-mode-color : color($color-palette , "secondary" , 200 )
);
scss
テーマを適用
テーマを適用する最も簡単な方法は、グローバル スタイル ファイルに sass
@include
ステートメントを使用することです。
@include grid ($custom-grid-theme );
scss
デモ
上記の手順に加えて、セルの編集テンプレートに使用されるコントロールのスタイルを設定することもできます (input-group
、datepicker
および checkbox
)。
import { NgModule } from "@angular/core" ;
import { FormsModule } from "@angular/forms" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { IgxPreventDocumentScrollModule } from "./directives/prevent-scroll.directive" ;
import { IgxTreeGridModule } from "igniteui-angular" ;
import { TreeGridEditingStyleComponent } from "./tree-grid-editing-style/tree-grid-editing-sample.component" ;
@NgModule ({
bootstrap : [AppComponent],
declarations : [
AppComponent,
TreeGridEditingStyleComponent
],
imports : [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
IgxPreventDocumentScrollModule,
IgxTreeGridModule
],
providers : [],
entryComponents : [],
schemas : []
})
export class AppModule {}
ts コピー import { Component, OnInit, ViewChild } from '@angular/core' ;
import { IgxTreeGridComponent } from 'igniteui-angular' ;
import { generateEmployeeFlatData } from '../data/employees-flat' ;
@Component ({
selector : 'app-tree-grid-editing-sample' ,
styleUrls : ['./tree-grid-editing-sample.component.scss' ],
templateUrl : './tree-grid-editing-sample.component.html'
})
export class TreeGridEditingStyleComponent implements OnInit {
@ViewChild (IgxTreeGridComponent, { static : true }) public treeGrid: IgxTreeGridComponent;
public data: any [];
constructor ( ) {
}
public ngOnInit(): void {
this .data = generateEmployeeFlatData();
}
}
ts コピー <div class ="grid__wrapper" >
<igx-tree-grid [igxPreventDocumentScroll ]="true" #treeGrid [data ]="data" primaryKey ="ID" foreignKey ="ParentID" [autoGenerate ]="false"
width ="100%" height ="800px" [allowFiltering ]="true" >
<igx-paginator [perPage ]="10" > </igx-paginator >
<igx-column [field ]="'Name'" dataType ="string" [editable ]="true" > </igx-column >
<igx-column [field ]="'Title'" dataType ="string" [editable ]="true" > </igx-column >
<igx-column [field ]="'Age'" dataType ="number" [editable ]="true" > </igx-column >
<igx-column [field ]="'HireDate'" dataType ="date" [editable ]="true" > </igx-column >
<igx-column [field ]="'OnPTO'" dataType ="boolean" [editable ]="true" width ="130px" >
<ng-template igxCell let-cell ="cell" let-val >
<igx-icon [style.color ]="cell.row.data.OnPTO? 'red': 'green'" > account_circle</igx-icon >
</ng-template >
</igx-column >
</igx-tree-grid >
</div >
html コピー @use '../../variables' as *;
$white : #fff ;
$blue : #4567bb ;
$color-palette : palette($primary : $white , $secondary : $blue , $surface : #fff );
$grid-theme : grid-theme(
$cell-editing-background : $blue ,
$cell-active-border-color : $white ,
$cell-edited-value-color : $white ,
$edit-mode-color : color($color-palette , "secondary" , 200 )
);
$checkbox-theme : checkbox-theme(
$empty-color : color($color-palette , "secondary" , 200 ),
$fill-color : $white ,
$tick-color : $blue
);
$datepicker-theme : calendar-theme(
$date-selected-text-color : $white ,
$date-selected-background : $blue
);
$input-theme : input-group-theme(
$filled-text-color : $white ,
$focused-text-color : $white ,
$idle-text-color : $white ,
$idle-bottom-line-color : $white ,
$focused-bottom-line-color : $white ,
$interim-bottom-line-color : $white ,
$hover-bottom-line-color : $white ,
$box-background : $blue
);
:host {
padding : 3px 10px ;
@include palette($color-palette );
::ng-deep {
.igx-grid__tbody{
@include css-vars($input-theme );
}
@include css-vars($checkbox-theme );
@include css-vars($datepicker-theme );
@include css-vars($grid-theme );
}
}
.igx-tree-grid {
margin-top : 10px ;
}
scss コピー
このサンプルは、Change Theme
(テーマの変更) から選択したグローバル テーマに影響を受けません。
API リファレンス
その他のリソース