Angular Tree Grid 集計
Ignite UI for Angular の Angular UI グリッドには、グループ フッターとして列レベルで集計できる機能があります。Angular グリッド集計は、列内のデータ タイプに応じて、あるいは Tree Grid にカスタム Angular テンプレートを実装することによって、定義済みのデフォルト集計項目を使用して別のコンテナーの列情報を表示できます。
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,
IgxIconModule
} from "igniteui-angular";
import { TreeGridSummarySampleComponent } from "./tree-grid-summary-sample/tree-grid-summary-sample.component";
@NgModule({
bootstrap: [AppComponent],
declarations: [
AppComponent,
TreeGridSummarySampleComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
IgxPreventDocumentScrollModule,
IgxTreeGridModule,
IgxIconModule
],
providers: [],
entryComponents: [],
schemas: []
})
export class AppModule {}
ts
import { Component, ViewChild } from '@angular/core';
import { ColumnType, IgxTreeGridComponent } from 'igniteui-angular';
import { FOODS_DATA } from '../data/foods';
@Component({
selector: 'app-tree-grid-summary-sample',
styleUrls: ['./tree-grid-summary-sample.component.scss'],
templateUrl: './tree-grid-summary-sample.component.html'
})
export class TreeGridSummarySampleComponent {
@ViewChild('treegrid1', { read: IgxTreeGridComponent, static: true })
public grid1: IgxTreeGridComponent;
public data;
constructor() {
this.data = FOODS_DATA();
}
public toggleSummary(column: ColumnType) {
column.hasSummary = !column.hasSummary;
}
}
ts
<div class="grid__wrapper">
<igx-tree-grid [igxPreventDocumentScroll]="true" #treegrid1 [data]="data" [autoGenerate]="false" height="700px" width="100%"
primaryKey="ID" foreignKey="ParentID">
<igx-column #col field="ID" header="Product ID">
</igx-column>
<igx-column #col field="Name" header="Product Name" [hasSummary]="true">
<ng-template igxCell let-cell="cell" let-val>
{{ val }}
</ng-template>
<ng-template igxHeader let-col>
<div class="text">{{col.field}}</div>
<igx-icon class="header-icon" style.color="{{ col.hasSummary ? '#e41c77' : '' }}" (click)="toggleSummary(col)">functions</igx-icon>
</ng-template>
</igx-column>
<igx-column #col field="UnitPrice" header="Price" [filterable]="false" [editable]="true" dataType="number"
[hasSummary]="true">
<ng-template igxCell let-cell="cell" let-val let-row>
${{ val }}
</ng-template>
<ng-template igxHeader let-col>
<div class="text">Price</div>
<igx-icon class="header-icon" style.color="{{ col.hasSummary ? '#e41c77' : '' }}" (click)="toggleSummary(col)">functions</igx-icon>
</ng-template>
</igx-column>
<igx-column #col field="Discontinued" header="Discontinued" [hasSummary]="true" [dataType]="'boolean'">
<ng-template igxCell let-cell="cell" let-val>
<img *ngIf="val" src="https://www.infragistics.com/angular-demos-lob/assets/images/grid/active.png" title="Continued" alt="Continued" />
<img *ngIf="!val" src="https://www.infragistics.com/angular-demos-lob/assets/images/grid/expired.png" title="Discontinued" alt="Discontinued" />
</ng-template>
<ng-template igxHeader let-col>
<div class="text">{{ col.field }}</div>
<igx-icon class="header-icon" style.color="{{ col.hasSummary ? '#e41c77' : '' }}" (click)="toggleSummary(col)">functions</igx-icon>
</ng-template>
</igx-column>
<igx-column #col field="AddedDate" header="Added Date" [dataType]="'date'" [hasSummary]="true">
<ng-template igxCell let-cell="cell" let-val let-row>
{{ val | date: 'MMM d, yyyy' }}
</ng-template>
<ng-template igxHeader let-col>
<div class="text">Added Date</div>
<igx-icon class="header-icon" style.color="{{ col.hasSummary ? '#e41c77' : '' }}" (click)="toggleSummary(col)">functions</igx-icon>
</ng-template>
</igx-column>
</igx-tree-grid>
</div>
html
:host{
::ng-deep {
.grid-controls {
display: flex;
flex-flow: column nowrap;
justify-content: space-between;
margin: 0 16px 24px;
igx-switch {
margin-top: 24px;
}
}
.header {
height: 100%;
}
.igx-grid__th .title{
width: 100%;
cursor: auto;
}
}
}
.grid__wrapper {
margin: 0 16px;
padding-top: 16px;
}
@media screen and (max-width: 677px){
[class*=header-icon]{
padding-bottom: 17px;
padding-top: 17px;
font-size: 1.4em;
width: 1.1em;
height: 1.1em;
float: right;
}
[class*=text]{
float:left;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 50%;
}
}
@media screen and (min-width: 677px){
[class*=header-icon]{
padding-top: 17px;
font-size: 1.4em;
width: 1.1em;
height: 1.1em;
float: right;
}
[class*=text] {
float:left;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 50%;
}
}
@media screen and (min-width: 992px){
[class*=header-icon] {
padding-top: 17px;
font-size: 1.4em;
width: 1.1em;
height: 1.1em;
float: right;
margin-right: 10px;
cursor: pointer;
}
[class*=text] {
float:left;
white-space: nowrap;
width: 50%;
cursor: auto;
}
}
scss
このサンプルが気に入りましたか? 完全な Ignite UI for Angularツールキットにアクセスして、すばやく独自のアプリの作成を開始します。無料でダウンロードできます。
列の集計は列値すべての関数ですが、フィルタリングが適用された場合、列の集計はフィルターされた結果値の関数になります。
Tree Grid 集計を列ごとに有効にして必要な列のみアクティブ化できます。Tree Grid 集計は、列のデータ型に基づいてデフォルト集計の定義済みセットを提供します。
string
と boolean
data types
の場合、データ型の場合、以下の関数が利用できます。
number
、currency
、および percent
データ型の場合、以下の関数を使用できます。
- count
- min
- max
- average
- sum
date
データ型の場合、以下の関数が利用できます。
すべての利用可能な列データ型は、公式の列タイプ トピックにあります。
hasSummary
プロパティを true
に設定すると Tree Grid 集計が列レベルで有効になります。各列の集計は列のデータ型に基づいて解決されます。igx-tree-grid
のデフォルトの列データ型は string
のため、number
または date
固有の集計を適用するには、dataType
プロパティを number
または date
に設定します。集計値は、グリッドの locale
および列 pipeArgs
に従ってローカライズされて表示されます。
<igx-tree-grid #grid1 [data]="data" [autoGenerate]="false" height="800px" width="800px" (columnInit)="initColumn($event)">
<igx-column field="ID" header="Order ID" width="200px" [sortable]="true"></igx-column>
<igx-column field="Name" header="Order Product" width="200px" [sortable]="true" [hasSummary]="true"></igx-column>
<igx-column field="Units" width="200px" [editable]="true" [dataType]="'number'" [hasSummary]="true"></igx-column>
</igx-tree-grid>
html
特定の列や列のリストを有効または無効にする他の方法として igx-tree-grid のパブリック メソッド enableSummaries
/disableSummaries
を使用する方法があります。
<igx-tree-grid #grid1 [data]="data" [autoGenerate]="false" height="800px" width="800px" (columnInit)="initColumn($event)" >
<igx-column field="ID" header="Order ID" width="200px" [sortable]="true"></igx-column>
<igx-column field="Name" header="Order Product" width="200px" [sortable]="true" [hasSummary]="true" ></igx-column>
<igx-column field="Units" width="200px" [editable]="true" [dataType]="'number'" [hasSummary]="false"></igx-column>
</igx-tree-grid>
<button (click)="enableSummary()">Enable Summary</button>
<button (click)="disableSummary()">Disable Summary </button>
html
public enableSummary() {
this.grid1.enableSummaries([
{fieldName: 'Units', customSummary: this.mySummary},
{fieldName: 'ID'}
]);
}
public disableSummary() {
this.grid1.disableSummaries('Name');
}
typescript
カスタム Tree Grid 集計
この関数が要件に合わない場合、指定した列にカスタム集計を提供できます。これには、基本クラス IgxSummaryOperand
、IgxNumberSummaryOperand
、IgxDateSummaryOperand
のいずれかを列データ型や必要に応じてオーバーライドします。このように既存の関数を再定義、または新しい関数を追加できます。IgxSummaryOperand
クラスは、count
メソッドにデフォルト実装のみを提供します。IgxNumberSummaryOperand
は IgxSummaryOperand
を拡張し、min
、max
、sum
、average
を提供します。IgxDateSummaryOperand
は IgxSummaryOperand
を拡張し、追加で earliest
と latest
を提供します。
import { IgxSummaryResult, IgxSummaryOperand, IgxNumberSummaryOperand, IgxDateSummaryOperand } from 'igniteui-angular';
class MySummary extends IgxNumberSummaryOperand {
constructor() {
super();
}
operate(data?: any[]): IgxSummaryResult[] {
const result = super.operate(data);
result.push({
key: 'test',
label: 'Test',
summaryResult: data.filter(rec => rec > 10 && rec < 30).length
});
return result;
}
}
typescript
例に表示されるように、基本クラスは operate
メソッドを公開しているため、すべてのデフォルト集計を取得して結果を変更するか、まったく新しい集計結果を計算することができます。
このメソッドは IgxSummaryResult
のリストを返し、集計を計算するためのオプションのパラメーターを取得します。
interface IgxSummaryResult {
key: string;
label: string;
summaryResult: any;
}
typescript
以下の「すべてのデータにアクセスするカスタム集計」セクションを参照してください。
UnitPrice
列にカスタム集計を追加します。summaries
プロパティを以下に作成するクラスに設定します。
<igx-tree-grid #grid1 [data]="data" [autoGenerate]="false" height="800px" width="800px" (columnInit)="initColumn($event)">
<igx-column field="ID" header="Order ID" width="200px" [sortable]="true"></igx-column>
<igx-column field="Name" header="Order Product" width="200px" [sortable]="true" [hasSummary]="true"></igx-column>
<igx-column field="Units" [dataType]="'number'" width="200px" [editable]="true" [hasSummary]="true" [summaries]="mySummary"></igx-column>
<igx-column field="UnitPrice" header="Unit Price" width="200px" [dataType]="'number'" [dataType]="'currency'" [hasSummary]="true"></igx-column>
</igx-tree-grid>
html
...
export class GridComponent implements OnInit {
mySummary = MySummary;
....
}
typescript
すべてのデータにアクセスするカスタム集計
カスタム列集計内のすべての Tree Grid データにアクセスできます。IgxSummaryOperand operate
メソッドには、2 つの追加のオプション パラメーターが導入されています。
以下のコード スニペットで示されるように operate メソッドには以下の 3 つのパラメーターがあります。
- columnData - 現在の列の値のみを含む配列を提供します。
- allGridData - グリッド データソース全体を提供します。
- fieldName - 現在の列フィールド。
class MySummary extends IgxNumberSummaryOperand {
constructor() {
super();
}
operate(columnData: any[], allGridData = [], fieldName?): IgxSummaryResult[] {
const result = super.operate(allData.map(r => r[fieldName]));
result.push({ key: 'test', label: 'Total Undelivered', summaryResult: allData.filter((rec) => rec.Discontinued).length });
return result;
}
}
typescript
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 { TreeGridAllDataSummaryComponent } from "./tree-grid/treegrid-allData-summary/treegrid-allData-summary.component";
@NgModule({
bootstrap: [AppComponent],
declarations: [
AppComponent,
TreeGridAllDataSummaryComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
IgxPreventDocumentScrollModule,
IgxTreeGridModule
],
providers: [],
entryComponents: [],
schemas: []
})
export class AppModule {}
ts
import { Component, OnInit, ViewChild } from '@angular/core';
import { IgxSummaryOperand, IgxSummaryResult, IgxTreeGridComponent } from 'igniteui-angular';
import { generateEmployeeFlatData } from '../data/employees-flat';
class PTOSummary {
public operate(data?: any[], allData = [], fieldName = ''): IgxSummaryResult[] {
const result = [];
result.push({
key: 'totalOnPTO', label: 'Employees On PTO',
summaryResult: IgxSummaryOperand.count(allData.filter((rec) => rec['OnPTO']).map(r => r[fieldName]))
});
result.push({
key: 'devs', label: 'Developers',
summaryResult: IgxSummaryOperand.count(
allData.filter((rec) => rec[fieldName].includes('Developer') && rec['OnPTO']).map(r => r[fieldName]))
});
result.push({
key: 'tl', label: 'Team Leads',
summaryResult: IgxSummaryOperand.count(
allData.filter((rec) => rec[fieldName].includes('Team Lead') && rec['OnPTO']).map(r => r[fieldName]))
});
result.push({
key: 'managers', label: 'Managers/Directors',
summaryResult: IgxSummaryOperand.count(
allData.filter((rec) =>
(rec[fieldName].includes('Manager') || rec[fieldName].includes('Director')) && rec['OnPTO'])
.map(r => r[fieldName]))
});
result.push({
key: 'ceo', label: 'CEO/President',
summaryResult: IgxSummaryOperand.count(
allData.filter((rec) =>
(rec[fieldName].includes('CEO') || rec[fieldName].includes('President')) && rec['OnPTO'])
.map(r => r[fieldName]))
});
return result;
}
}
@Component({
selector: 'app-treegrid-all-data-summary-sample',
styleUrls: ['./treegrid-allData-summary.component.scss'],
templateUrl: './treegrid-allData-summary.component.html'
})
export class TreeGridAllDataSummaryComponent implements OnInit {
@ViewChild('treegrid1', { read: IgxTreeGridComponent, static: true })
public grid1: IgxTreeGridComponent;
public data;
public d;
public ptoSummary = PTOSummary;
constructor() { }
public ngOnInit() {
this.data = generateEmployeeFlatData();
this.data.forEach(rec => rec.Title = rec.Title.includes('Localiza') ? 'Software Developer' : rec.Title);
}
}
ts
<div class="grid__wrapper">
<div class="sample-wrapper">
<igx-tree-grid [igxPreventDocumentScroll]="true" #treeGrid [data]="data" cellSelection="single" primaryKey="ID"
foreignKey="ParentID" height="620px" width="100%" [displayDensity]="'compact'">
<igx-column field="Name"></igx-column>
<igx-column field="Age" width="15%" ></igx-column>
<igx-column field="Title" [hasSummary]="true" [summaries]="ptoSummary"></igx-column>
<igx-column field="HireDate" [dataType]="'date'" [hasSummary]="true"></igx-column>
<igx-column field="OnPTO" width="15%" [dataType]="'boolean'" [editable]="true" [hasSummary]="true"></igx-column>
</igx-tree-grid>
</div>
</div>
html
.grid__wrapper{
padding: 16px;
}
scss
集計テンプレート
igxSummary
は、列の集計の結果をコンテキストとして提供する列の集計を対象としています。
<igx-column ... [hasSummary]="true">
<ng-template igxSummary let-summaryResults>
<span> My custom summary template</span>
<span>{{ summaryResults[0].label }} - {{ summaryResults[0].summaryResult }}</span>
</ng-template>
</igx-column>
html
デフォルトの集計が定義されている場合、集計領域の高さは、集計の数が最も多い列とグリッドのサイズに応じてデザインにより計算されます。summaryRowHeight 入力プロパティを使用して、デフォルト値をオーバーライドします。引数として数値が必要であり、false 値を設定すると、グリッド フッターのデフォルトのサイズ設定動作がトリガーされます。
列の集計テンプレートは、列 summaryTemplate プロパティを必要な TemplateRef に設定することにより、API を介して定義できます。
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,
IgxInputGroupModule,
IgxButtonGroupModule,
IgxSwitchModule
} from "igniteui-angular";
import { TreeGridSummaryTemplateComponent } from "./tree-grid/treegrid-summary-template/treegrid-summary-template.component";
@NgModule({
bootstrap: [AppComponent],
declarations: [
AppComponent,
TreeGridSummaryTemplateComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
IgxPreventDocumentScrollModule,
IgxTreeGridModule,
IgxInputGroupModule,
IgxButtonGroupModule,
IgxSwitchModule
],
providers: [],
entryComponents: [],
schemas: []
})
export class AppModule {}
ts
import { Component, OnInit } from '@angular/core';
import { DisplayDensity, IgxSummaryOperand, IgxSummaryResult } from 'igniteui-angular';
import { generateEmployeeFlatData } from '../data/employees-flat';
class PTOSummary {
public operate(data?: any[], allData = [], fieldName = ''): IgxSummaryResult[] {
const result = [];
result.push({
key: 'totalOnPTO', label: 'Employees On PTO',
summaryResult: IgxSummaryOperand.count(allData.filter((rec) => rec['OnPTO']).map(r => r[fieldName]))
});
result.push({
key: 'devs', label: 'Developers',
summaryResult: IgxSummaryOperand.count(
allData.filter((rec) => rec[fieldName].includes('Developer') && rec['OnPTO']).map(r => r[fieldName]))
});
result.push({
key: 'tl', label: 'Team Leads',
summaryResult: IgxSummaryOperand.count(
allData.filter((rec) => rec[fieldName].includes('Team Lead') && rec['OnPTO']).map(r => r[fieldName]))
});
result.push({
key: 'managers', label: 'Managers/Directors',
summaryResult: IgxSummaryOperand.count(
allData.filter((rec) =>
(rec[fieldName].includes('Manager') || rec[fieldName].includes('Director')) && rec['OnPTO'])
.map(r => r[fieldName]))
});
result.push({
key: 'ceo', label: 'CEO/President',
summaryResult: IgxSummaryOperand.count(
allData.filter((rec) =>
(rec[fieldName].includes('CEO') || rec[fieldName].includes('President')) && rec['OnPTO'])
.map(r => r[fieldName]))
});
return result;
}
}
@Component({
selector: 'app-treegrid-summary-template',
styleUrls: ['./treegrid-summary-template.component.scss'],
templateUrl: './treegrid-summary-template.component.html'
})
export class TreeGridSummaryTemplateComponent implements OnInit {
public data;
public d;
public ptoSummary = PTOSummary;
public summaryHeight = 150;
public displayDensity: DisplayDensity = 'cosy';
public displayDensities;
public hasSummary = true;
constructor() { }
public ngOnInit(): void {
this.data = generateEmployeeFlatData();
this.data.forEach(rec => rec.Title = rec.Title.includes('Localiza') ? 'Software Developer' : rec.Title);
this.displayDensities = [
{ label: 'compact', selected: this.displayDensity === 'compact', togglable: true },
{ label: 'cosy', selected: this.displayDensity === 'cosy', togglable: true },
{ label: 'comfortable', selected: this.displayDensity === 'comfortable', togglable: true }
];
}
public selectDensity(event): void {
this.displayDensity = this.displayDensities[event.index].label;
}
}
ts
<div class="sample__wrapper">
<div class="controls-wrapper">
<igx-input-group>
<label igxLabel for="height">Summary Row Height</label>
<input igxInput id="height" name="height" type="number" [(ngModel)]="summaryHeight">
</igx-input-group>
<igx-switch [(ngModel)]="hasSummary">Toggle Summaries</igx-switch>
<igx-buttongroup [values]="displayDensities" (selected)="selectDensity($event)" [displayDensity]="displayDensity">
</igx-buttongroup>
</div>
<igx-tree-grid [igxPreventDocumentScroll]="true" #treeGrid [data]="data" cellSelection="single" primaryKey="ID"
foreignKey="ParentID" height="520px" width="100%" [summaryRowHeight]="summaryHeight"
[displayDensity]="displayDensity">
<igx-column field="Name"></igx-column>
<igx-column field="Age" dataType="number" width="15%" [hasSummary]="hasSummary">
<ng-template igxSummary let-summaryResults>
<div class="summary-temp">
<span><strong>{{ summaryResults[0].label }}</strong><span>{{ summaryResults[0].summaryResult }}</span></span>
<span><strong>{{ summaryResults[1].label }}</strong><span>{{ summaryResults[1].summaryResult }}</span></span>
<span><strong>{{ summaryResults[2].label }}</strong><span>{{ summaryResults[2].summaryResult }}</span></span>
<span><strong>{{ summaryResults[3].label }}</strong><span>{{ summaryResults[3].summaryResult }}</span></span>
</div>
</ng-template>
</igx-column>
<igx-column field="Title" [hasSummary]="hasSummary" [summaries]="ptoSummary"></igx-column>
<igx-column field="HireDate" [dataType]="'date'"></igx-column>
<igx-column field="OnPTO" width="15%" [dataType]="'boolean'" [editable]="true" [hasSummary]="hasSummary">
</igx-column>
</igx-tree-grid>
</div>
html
.sample__wrapper {
display: flex;
flex-direction: column;
gap: 16px;
padding: 16px;
height: 100%;
overflow-y: auto;
}
igx-buttongroup {
max-width: 450px;
flex: 1;
}
.summary-temp {
display: flex;
flex-direction: column;
margin: 0 1px;
font-size: 14px;
line-height: 24px;
height: 100%;
overflow-y: auto;
overflow-x: hidden;
span {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 4px;
justify-content: space-between;
color: hsla(var(--igx-gray-900));
span {
user-select: all;
max-width: 300px;
padding-right: 8px;
}
strong {
font-size: 12px;
text-transform: uppercase;
min-width: 70px;
justify-self: flex-start;
text-align: left;
color: hsla(var(--ig-secondary-600));
user-select: none;
}
}
> * {
padding: 8px 0;
line-height: 18px;
border-bottom: 1px dashed hsla(var(--igx-gray-400));
&:last-child {
border-bottom: none;
}
}
}
::-webkit-scrollbar {
width: 5px !important;
height: 5px !important;
}
.controls-wrapper {
display: flex;
align-items: center;
flex-direction: row;
gap: 16px;
}
scss
集計の無効化
disabledSummaries
プロパティは、Ignite UI for Angular グリッド集計機能に対して列ごとに正確な制御を提供します。このプロパティを使用すると、グリッド内の各列に表示される集計をカスタマイズして、最も関連性の高い意味のあるデータのみが表示されるようにすることができます。たとえば、配列で集計キーを指定することにより、['count', 'min', 'max']
などの特定の集計タイプを除外できます。
このプロパティは、コードを通じて実行時に動的に変更することもできるため、変化するアプリケーションの状態やユーザー操作に合わせてグリッドの集計を柔軟に調整できます。
次の例は、disabledSummaries
プロパティを使用してさまざまな列の集計を管理し、Ignite UI for Angular グリッドで特定のデフォルトおよびカスタムの集計タイプを除外する方法を示しています。
<igx-column
field="Units"
header="Units"
dataType="number"
[hasSummary]="true"
[summaries]="unitsSummary"
[disabledSummaries]="['uniqueCount', 'maxDifference']"
>
</igx-column>
<igx-column
field="UnitPrice"
header="Unit Price"
dataType="number"
[hasSummary]="true"
[disabledSummaries]="['count', 'sum', 'average']"
>
</igx-column>
html
Units
の場合、totalDelivered
や totalNotDelivered
などのカスタム集計は disabledSummaries
プロパティを使用して除外されます。
UnitPrice
の場合、count
、sum
、average
などのデフォルトの集計は無効になっており、min
や max
などの他の集計は有効のままになっています。
実行時に、disabledSummaries
プロパティを使用して集計を動的に無効にすることもできます。たとえば、特定の列のプロパティをプログラムで設定または更新して、ユーザー操作やアプリケーションの状態の変化に基づいて表示される集計を調整できます。
集計のフォーマット
デフォルトでは、組み込みの集計オペランドによって生成される集計結果は、グリッド locale
および列 pipeArgs
に従ってローカライズおよびフォーマットされます。カスタム オペランドを使用する場合、locale
と pipeArgs
は適用されません。集計結果のデフォルトの外観を変更する場合は、summaryFormatter
プロパティを使用してフォーマットできます。
public dateSummaryFormat(summary: IgxSummaryResult, summaryOperand: IgxSummaryOperand): string {
const result = summary.summaryResult;
if(summaryOperand instanceof IgxDateSummaryOperand && summary.key !== 'count'
&& result !== null && result !== undefined) {
const pipe = new DatePipe('en-US');
return pipe.transform(result,'MMM YYYY');
}
return result;
}
typescript
<igx-column ... [summaryFormatter]="dateSummaryFormat"></igx-column>
html
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 { TreeGridSummaryFormatterComponent } from "./tree-grid-summary-formatter/tree-grid-summary-formatter.component";
import { IgxTreeGridModule } from "igniteui-angular";
import { IgxPreventDocumentScrollModule } from "./directives/prevent-scroll.directive";
@NgModule({
bootstrap: [AppComponent],
declarations: [
AppComponent,
TreeGridSummaryFormatterComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
IgxPreventDocumentScrollModule,
IgxTreeGridModule
],
providers: [],
entryComponents: [],
schemas: []
})
export class AppModule {}
ts
import { DatePipe } from '@angular/common';
import { Component, OnInit, ViewChild } from '@angular/core';
import { IgxDateSummaryOperand, IgxSummaryResult, IgxSummaryOperand, IgxTreeGridComponent } from 'igniteui-angular';
import { FOODS_DATA } from '../data/foods';
@Component({
selector: 'app-tree-grid-summary-formatter',
styleUrls: ['./tree-grid-summary-formatter.component.scss'],
templateUrl: 'tree-grid-summary-formatter.component.html'
})
export class TreeGridSummaryFormatterComponent implements OnInit {
@ViewChild('treegrid1', { read: IgxTreeGridComponent, static: true })
public treegrid1: IgxTreeGridComponent;
public data: any[];
public ngOnInit(): void {
this.data = FOODS_DATA();
}
public dateSummaryFormat(summary: IgxSummaryResult, summaryOperand: IgxSummaryOperand): string {
const result = summary.summaryResult;
if (summaryOperand instanceof IgxDateSummaryOperand && summary.key !== 'count'
&& result !== null && result !== undefined) {
const pipe = new DatePipe('en-US');
return pipe.transform(result, 'MMM YYYY');
}
return result;
}
}
ts
<div class="grid__wrapper">
<igx-tree-grid [igxPreventDocumentScroll]="true" #treegrid1 [data]="data" [autoGenerate]="false" height="600px" width="100%"
[allowFiltering]="true" filterMode="excelStyleFilter"
primaryKey="ID" foreignKey="ParentID">
<igx-column field="ID" header="Product ID" [dataType]="'string'" [sortable]="true" [disableHiding]="true">
</igx-column>
<igx-column field="Name" header="Product Name" [dataType]="'string'" [sortable]="true" [disableHiding]="true">
</igx-column>
<igx-column field="UnitPrice" header="Unit Price Category" dataType="string" [sortable]="true" [disableHiding]="true">
</igx-column>
<igx-column field="AddedDate" header="Added Date" [dataType]="'date'" [sortable]="true" [disableHiding]="true"
[hasSummary]="true" [summaryFormatter]="dateSummaryFormat">
</igx-column>
<igx-column field="Discontinued" header="Discontinued" [dataType]="'boolean'" [sortable]="true" [disableHiding]="true">
<ng-template igxCell let-cell="cell" let-val>
<span *ngIf="cell.row.data.UnitPrice === 0">-</span>
<img *ngIf="cell.row.data.UnitPrice !== 0 && val" src="https://www.infragistics.com/angular-demos-lob/assets/images/grid/active.png" title="Continued" alt="Continued" />
<img *ngIf="cell.row.data.UnitPrice !== 0 && !val" src="https://www.infragistics.com/angular-demos-lob/assets/images/grid/expired.png" title="Discontinued" alt="Discontinued" />
</ng-template>
</igx-column>
</igx-tree-grid>
</div>
html
.grid__wrapper {
margin: 16px;
}
scss

子集計
Tree Grid はルート ノードの集計と各ネストされた子ノード レベルの区別をサポートします。集計は summaryCalculationMode
プロパティを使用して設定できます。子レベル集計は、summaryPosition
を使用して子ノードの前または後に表示できます。これら 2 つのプロパティに加えて、IgxTreeGrid は、参照する親ノードが縮小されたときに集計行が表示されたままであるかどうかを決定でき showSummaryOnCollapse
プロパティを公開します。
以下は、使用可能な summaryCalculationMode
プロパティの値です。
- rootLevelOnly - ルート レベルのノードのみ集計が計算されます。
- childLevelsOnly - 子レベルのみ集計が計算されます。
- rootAndChildLevels - ルートと子レベルの両方の集計が計算されます。これがデフォルト値です。
以下は、使用可能な summaryPosition
プロパティの値です。
- top - 集計行は子行のリストの前に表示されます。
- bottom - 集計行は子行のリストの後に表示されます。これがデフォルト値です。
showSummaryOnCollapse
プロパティはブール値です。デフォルト値は false に設定されています。これは、親行が縮小されたときに集計行が非表示になることを意味します。プロパティが true に設定されている場合、親行が縮小されたときに、集計行は表示されたままになります。
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 {
IgxButtonModule,
IgxButtonGroupModule,
IgxTreeGridModule,
IgxIconModule,
IgxSwitchModule
} from "igniteui-angular";
import { TreeGridSummary2SampleComponent } from "./tree-grid-summary2-sample/tree-grid-summary2-sample.component";
@NgModule({
bootstrap: [AppComponent],
declarations: [
AppComponent,
TreeGridSummary2SampleComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
IgxPreventDocumentScrollModule,
IgxButtonModule,
IgxButtonGroupModule,
IgxTreeGridModule,
IgxIconModule,
IgxSwitchModule
],
providers: [],
entryComponents: [],
schemas: []
})
export class AppModule {}
ts
import { Component, OnInit, ViewChild } from '@angular/core';
import {
DefaultSortingStrategy,
GridSummaryCalculationMode,
GridSummaryPosition,
IgxNumberSummaryOperand,
IgxSummaryOperand,
IgxSummaryResult,
IgxTreeGridComponent,
ISortingExpression,
SortingDirection
} from 'igniteui-angular';
import { FOODS_DATA } from '../data/foods';
class AvgSummary {
public operate(data?: any[]): IgxSummaryResult[] {
const result = [];
const avg = IgxNumberSummaryOperand.average(data);
result.push({
key: 'avg',
label: 'Average',
summaryResult: data.length ? '$' + avg.toFixed(2) : ''
});
return result;
}
}
@Component({
selector: 'app-tree-grid-summary2-sample',
styleUrls: ['./tree-grid-summary2-sample.component.scss'],
templateUrl: './tree-grid-summary2-sample.component.html'
})
export class TreeGridSummary2SampleComponent implements OnInit {
@ViewChild('treegrid1', { read: IgxTreeGridComponent, static: true })
public grid1: IgxTreeGridComponent;
public data;
public expr: ISortingExpression[];
public avgSummary = AvgSummary;
public summaryPositions;
public summaryPosition: GridSummaryPosition = GridSummaryPosition.bottom;
public summaryCalcModes;
public summaryCalculationMode: GridSummaryCalculationMode = GridSummaryCalculationMode.rootAndChildLevels;
constructor() {
this.data = FOODS_DATA();
this.expr = [
{
dir: SortingDirection.Asc,
fieldName: 'ShipCountry',
ignoreCase: false,
strategy: DefaultSortingStrategy.instance()
}
];
this.summaryPositions = [
{
label: GridSummaryPosition.top,
selected: this.summaryPosition === GridSummaryPosition.top,
togglable: true
},
{
label: GridSummaryPosition.bottom,
selected: this.summaryPosition === GridSummaryPosition.bottom,
togglable: true
}
];
this.summaryCalcModes = [
{
label: 'Root Level Only',
selected: this.summaryCalculationMode === GridSummaryCalculationMode.rootLevelOnly,
togglable: true,
value: GridSummaryCalculationMode.rootLevelOnly
},
{
label: 'Child Levels Only',
selected: this.summaryCalculationMode === GridSummaryCalculationMode.childLevelsOnly,
togglable: true,
value: GridSummaryCalculationMode.childLevelsOnly
},
{
label: 'Root And Child Levels',
selected: this.summaryCalculationMode === GridSummaryCalculationMode.rootAndChildLevels,
togglable: true,
value: GridSummaryCalculationMode.rootAndChildLevels
}
];
}
public ngOnInit() {
this.grid1.sortingExpressions = [
{ dir: SortingDirection.Desc, fieldName: 'ID',
ignoreCase: true, strategy: DefaultSortingStrategy.instance() }
];
}
public selectSummaryPosition(event) {
this.summaryPosition = this.summaryPositions[event.index].label;
this.grid1.summaryPosition = this.summaryPosition;
}
public selectSummaryCalcMode(event) {
this.summaryCalculationMode = this.summaryCalcModes[event.index].value;
this.grid1.summaryCalculationMode = this.summaryCalculationMode;
}
public toggle(event) {
this.grid1.showSummaryOnCollapse = !this.grid1.showSummaryOnCollapse;
}
public formatCurrency(value: number) {
return '$' + value.toFixed(2);
}
}
ts
<div class="summary-chooser">
<igx-buttongroup [values]="summaryCalcModes" (selected)="selectSummaryCalcMode($event)"></igx-buttongroup>
</div>
<div class="summary-chooser">
<igx-buttongroup [values]="summaryPositions" (selected)="selectSummaryPosition($event)"></igx-buttongroup>
</div>
<div class="summary-chooser">
<igx-switch labelPosition="before" [checked]='treegrid1.showSummaryOnCollapse' (change)='toggle($event)'> Show summary row when group row is collapsed:</igx-switch>
</div>
<igx-tree-grid [igxPreventDocumentScroll]="true" #treegrid1 [data]="data" [autoGenerate]="false" height="500px" width="100%"
primaryKey="ID" foreignKey="ParentID">
<igx-column #col field="ID" header="Product ID" [sortable]="true">
</igx-column>
<igx-column #col field="Name" header="Product Name" [hasSummary]="true">
</igx-column>
<igx-column #col field="UnitPrice" header="Price" [formatter]="formatCurrency" [filterable]="false" [editable]="true" dataType="number"
[hasSummary]="true" [summaries]="avgSummary">
</igx-column>
<igx-column #col field="Discontinued" header="Discontinued" [dataType]="'boolean'">
<ng-template igxCell let-cell="cell" let-val>
<img *ngIf="val" src="https://www.infragistics.com/angular-demos-lob/assets/images/grid/active.png" title="Continued" alt="Continued" />
<img *ngIf="!val" src="https://www.infragistics.com/angular-demos-lob/assets/images/grid/expired.png" title="Discontinued" alt="Discontinued" />
</ng-template>
</igx-column>
<igx-column #col field="AddedDate" header="Added Date" [dataType]="'date'">
</igx-column>
</igx-tree-grid>
html
:host {
display: block;
padding: 8px;
}
.summary-chooser {
margin-bottom: 16px;
}
igx-buttongroup{
display: block;
width: 600px;
}
scss
集計のエクスポート
exportSummaries
オプションが IgxExcelExporterOptions
にあり、エクスポートされたデータにグリッドの集計を含めるかどうかを指定します。デフォルトの exportSummaries
値は false です。
IgxExcelExporterService
は、すべての列タイプのデフォルトの集計を同等の Excel 関数としてエクスポートするため、シートが変更された場合でも適切に機能し続けます。以下の例をご覧ください:
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,
IgxIconModule,
IgxExcelExporterService
} from "igniteui-angular";
import { TreeGridSummaryExportComponent } from "./tree-grid-summary-export/tree-grid-summary-export.component";
@NgModule({
bootstrap: [AppComponent],
declarations: [
AppComponent,
TreeGridSummaryExportComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
IgxPreventDocumentScrollModule,
IgxTreeGridModule,
IgxIconModule
],
providers: [IgxExcelExporterService],
entryComponents: [],
schemas: []
})
export class AppModule {}
ts
import { Component, ViewChild } from '@angular/core';
import { ColumnType, IgxExcelExporterOptions, IgxExcelExporterService, IgxTreeGridComponent } from 'igniteui-angular';
import { FOODS_DATA } from '../data/foods';
@Component({
selector: 'app-tree-grid-summary-export',
styleUrls: ['./tree-grid-summary-export.component.scss'],
templateUrl: './tree-grid-summary-export.component.html'
})
export class TreeGridSummaryExportComponent {
@ViewChild('tGrid', { read: IgxTreeGridComponent, static: true })
public tGrid: IgxTreeGridComponent;
public data;
constructor(private excelExportService: IgxExcelExporterService) {
this.data = FOODS_DATA();
}
public toggleSummary(column: ColumnType) {
column.hasSummary = !column.hasSummary;
}
public exportButtonHandler() {
this.excelExportService.export(this.tGrid, new IgxExcelExporterOptions('ExportedFile'));
}
}
ts
<div class="grid__wrapper">
<div class="button-container">
<button igxButton="raised" (click)="exportButtonHandler()">Export To Excel</button>
Press the button to export the Grid as a .xlsx file.
</div>
<igx-tree-grid [igxPreventDocumentScroll]="true" #tGrid [data]="data" [autoGenerate]="false" height="650px" width="100%"
primaryKey="ID" foreignKey="ParentID">
<igx-column #col field="ID" header="Product ID">
</igx-column>
<igx-column #col field="Name" header="Product Name" [hasSummary]="true">
<ng-template igxCell let-cell="cell" let-val>
{{ val }}
</ng-template>
<ng-template igxHeader let-col>
<div class="text">{{col.field}}</div>
<igx-icon class="header-icon" style.color="{{ col.hasSummary ? '#e41c77' : '' }}" (click)="toggleSummary(col)">functions</igx-icon>
</ng-template>
</igx-column>
<igx-column #col field="UnitPrice" header="Price" [filterable]="false" [editable]="true" dataType="number"
[hasSummary]="true">
<ng-template igxCell let-cell="cell" let-val let-row>
${{ val }}
</ng-template>
<ng-template igxHeader let-col>
<div class="text">Price</div>
<igx-icon class="header-icon" style.color="{{ col.hasSummary ? '#e41c77' : '' }}" (click)="toggleSummary(col)">functions</igx-icon>
</ng-template>
</igx-column>
<igx-column #col field="Discontinued" header="Discontinued" [hasSummary]="true" [dataType]="'boolean'">
<ng-template igxCell let-cell="cell" let-val>
<img *ngIf="val" src="https://www.infragistics.com/angular-demos-lob/assets/images/grid/active.png" title="Continued" alt="Continued" />
<img *ngIf="!val" src="https://www.infragistics.com/angular-demos-lob/assets/images/grid/expired.png" title="Discontinued" alt="Discontinued" />
</ng-template>
<ng-template igxHeader let-col>
<div class="text">{{ col.field }}</div>
<igx-icon class="header-icon" style.color="{{ col.hasSummary ? '#e41c77' : '' }}" (click)="toggleSummary(col)">functions</igx-icon>
</ng-template>
</igx-column>
<igx-column #col field="AddedDate" header="Added Date" [dataType]="'date'" [hasSummary]="true">
<ng-template igxCell let-cell="cell" let-val let-row>
{{ val | date: 'MMM d, yyyy' }}
</ng-template>
<ng-template igxHeader let-col>
<div class="text">Added Date</div>
<igx-icon class="header-icon" style.color="{{ col.hasSummary ? '#e41c77' : '' }}" (click)="toggleSummary(col)">functions</igx-icon>
</ng-template>
</igx-column>
</igx-tree-grid>
</div>
html
:host{
::ng-deep {
.grid-controls {
display: flex;
flex-flow: column nowrap;
justify-content: space-between;
margin: 0 16px 24px;
igx-switch {
margin-top: 24px;
}
}
.header {
height: 100%;
}
.igx-grid__th .title{
width: 100%;
cursor: auto;
}
}
}
.grid__wrapper {
margin: 0 16px;
padding-top: 16px;
}
@media screen and (max-width: 677px){
[class*=header-icon]{
padding-bottom: 17px;
padding-top: 17px;
font-size: 1.4em;
width: 1.1em;
height: 1.1em;
float: right;
}
[class*=text]{
float:left;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 50%;
}
}
@media screen and (min-width: 677px){
[class*=header-icon]{
padding-top: 17px;
font-size: 1.4em;
width: 1.1em;
height: 1.1em;
float: right;
}
[class*=text] {
float:left;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 50%;
}
}
@media screen and (min-width: 992px){
[class*=header-icon] {
padding-top: 17px;
font-size: 1.4em;
width: 1.1em;
height: 1.1em;
float: right;
margin-right: 10px;
cursor: pointer;
}
[class*=text] {
float:left;
white-space: nowrap;
width: 50%;
cursor: auto;
}
}
.button-container {
margin: 25px auto;
}
scss
エクスポートされたファイルには、シート内の各 DataRecord
のレベルを保持する非表示の列が含まれています。このレベルは、集計関数に含める必要があるセルを除外するために集計で使用されます。
以下の表では、デフォルトの各集計に対応する Excel 式を見つけることができます。
データ型 |
関数 |
Excel 関数 |
string 、boolean |
count |
="Count: "&COUNTIF(start:end, recordLevel) |
number 、currency 、percent |
count |
="Count: "&COUNTIF(start:end, recordLevel) |
|
min |
="Min: "&MIN(IF(start:end=recordLevel, rangeStart:rangeEnd)) |
|
max |
="Max: "&MAX(IF(start:end=recordLevel, rangeStart:rangeEnd)) |
|
average |
="Avg: "&AVERAGEIF(start:end, recordLevel, rangeStart:rangeEnd) |
|
sum |
="Sum: "&SUMIF(start:end, recordLevel, rangeStart:rangeEnd) |
date |
count |
="Count: "&COUNTIF(start:end, recordLevel) |
|
earliest |
="Earliest: "& TEXT(MIN(IF(start:end=recordLevel, rangeStart:rangeEnd)), format) |
|
latest |
="Latest: "&TEXT(MAX(IF(start:end=recordLevel, rangeStart:rangeEnd)), format) |
既知の問題と制限
制限 |
説明 |
カスタム集計のエクスポート |
カスタム集計は、Excel 関数ではなく文字列としてエクスポートされます。 |
テンプレート化された集計のエクスポート |
テンプレート化された集計はサポートされておらず、デフォルトのものとしてエクスポートされます。 |
キーボード ナビゲーション
集計行は、以下のキーボード操作でナビゲーションできます。
- UP - 1 つ上のセルへ移動。
- DOWN - 1 つ下のセルへ移動。
- LEFT - 1 つ左のセルへ移動。
- RIGHT - 1 つ右のセルへ移動。
- CTRL + LEFT または HOME - 左端のセルへ移動。
- CTRL + RIGHT または END - 右端のセルへ移動。
スタイル設定
ソート動作のスタイル設定は、すべてのテーマ関数とコンポーネント ミックスインが存在する index
ファイルをインポートする必要があります。
@use "igniteui-angular/theming" as *;
scss
最も簡単な方法は、grid-summary-theme
を拡張する新しいテーマを作成し、$background-color
、$focus-background-color
、$label-color
、$result-color
、$pinned-border-width
、$pinned-border-style
、および $pinned-border-color
パラメーターを受け取る方法です。
$custom-theme: grid-summary-theme(
$background-color: #e0f3ff,
$focus-background-color: rgba(#94d1f7, .3),
$label-color: #e41c77,
$result-color: black,
$pinned-border-width: 2px,
$pinned-border-style: dotted,
$pinned-border-color: #e41c77
);
scss
上記のようにカラーの値をハードコーディングする代わりに、palette
および color
関数を使用してカラーに関してより高い柔軟性を実現することができます。使い方の詳細についてはパレット
のトピックをご覧ください。
最後にコンポーネントのカスタム テーマを含めます。
@include css-vars($custom-theme);
scss
コンポーネントが Emulated
ViewEncapsulation を使用している場合、::ng-deep
を使用してこのカプセル化を解除する必要があります。
:host {
::ng-deep {
@include css-vars($custom-theme);
}
}
scss
デモ
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,
IgxIconModule
} from "igniteui-angular";
import { TreeGridSummaryStylingComponent } from "./tree-grid-summary-styling/tree-grid-summary-styling.component";
@NgModule({
bootstrap: [AppComponent],
declarations: [
AppComponent,
TreeGridSummaryStylingComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
IgxPreventDocumentScrollModule,
IgxTreeGridModule,
IgxIconModule
],
providers: [],
entryComponents: [],
schemas: []
})
export class AppModule {}
ts
import { Component, ViewChild } from '@angular/core';
import { ColumnType, IgxTreeGridComponent } from 'igniteui-angular';
import { FOODS_DATA } from '../data/foods';
@Component({
selector: 'app-tree-grid-summary-styling',
styleUrls: ['./tree-grid-summary-styling.component.scss'],
templateUrl: './tree-grid-summary-styling.component.html'
})
export class TreeGridSummaryStylingComponent {
@ViewChild('treegrid1', { read: IgxTreeGridComponent, static: true })
public grid1: IgxTreeGridComponent;
public data;
constructor() {
this.data = FOODS_DATA();
}
public toggleSummary(column: ColumnType) {
column.hasSummary = !column.hasSummary;
}
}
ts
<div class="grid__wrapper">
<igx-tree-grid [igxPreventDocumentScroll]="true" #treegrid1 [data]="data" [autoGenerate]="false" height="600px" width="100%"
primaryKey="ID" foreignKey="ParentID">
<igx-column #col field="ID" header="Product ID">
</igx-column>
<igx-column #col field="Name" header="Product Name" [hasSummary]="true">
<ng-template igxCell let-cell="cell" let-val>
{{ val }}
</ng-template>
<ng-template igxHeader let-col>
<div class="text">{{col.field}}</div>
<igx-icon style.color="{{ col.hasSummary ? '#e41c77' : '' }}" class="header-icon" (click)="toggleSummary(col)">functions</igx-icon>
</ng-template>
</igx-column>
<igx-column #col field="UnitPrice" header="Price" [filterable]="false" [editable]="true" dataType="number"
[hasSummary]="true">
<ng-template igxCell let-cell="cell" let-val let-row>
${{ val }}
</ng-template>
<ng-template igxHeader let-col>
<div class="text">Price</div>
<igx-icon style.color="{{ col.hasSummary ? '#e41c77' : '' }}" class="header-icon" (click)="toggleSummary(col)">functions</igx-icon>
</ng-template>
</igx-column>
<igx-column #col field="Discontinued" header="Discontinued" [hasSummary]="true" [dataType]="'boolean'">
<ng-template igxCell let-cell="cell" let-val>
<img *ngIf="val" src="https://www.infragistics.com/angular-demos-lob/assets/images/grid/active.png" title="Continued" alt="Continued" />
<img *ngIf="!val" src="https://www.infragistics.com/angular-demos-lob/assets/images/grid/expired.png" title="Discontinued" alt="Discontinued" />
</ng-template>
<ng-template igxHeader let-col>
<div class="text">{{ col.field }}</div>
<igx-icon style.color="{{ col.hasSummary ? '#e41c77' : '' }}" class="header-icon" (click)="toggleSummary(col)">functions</igx-icon>
</ng-template>
</igx-column>
<igx-column #col field="AddedDate" header="Added Date" [dataType]="'date'" [hasSummary]="true">
<ng-template igxCell let-cell="cell" let-val let-row>
{{ val | date: 'MMM d, yyyy' }}
</ng-template>
<ng-template igxHeader let-col>
<div class="text">Added Date</div>
<igx-icon style.color="{{ col.hasSummary ? '#e41c77' : '' }}" class="header-icon" (click)="toggleSummary(col)">functions</igx-icon>
</ng-template>
</igx-column>
</igx-tree-grid>
</div>
html
@use '../../variables' as *;
$custom-theme: grid-summary-theme(
$background-color: #e0f3ff,
$focus-background-color: rgba( #94d1f7, .3 ),
$label-color: #e41c77,
$result-color: black,
$pinned-border-width: 2px,
$pinned-border-style: dotted,
$pinned-border-color: #e41c77
);
:host{
::ng-deep {
@include css-vars($custom-theme);
.grid-controls {
display: flex;
flex-flow: column nowrap;
justify-content: space-between;
margin: 0 16px 24px;
igx-switch {
margin-top: 24px;
}
}
.header {
height: 100%;
}
.igx-grid__th .title{
width: 100%;
cursor: auto;
}
}
}
.grid__wrapper {
margin: 0 16px;
}
@media screen and (max-width: 677px){
[class*=header-icon]{
padding-bottom: 17px;
padding-top: 17px;
font-size: 1.4em;
width: 1.1em;
height: 1.1em;
float: right;
}
[class*=text]{
float:left;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 50%;
}
}
@media screen and (min-width: 677px){
[class*=header-icon]{
padding-top: 17px;
font-size: 1.4em;
width: 1.1em;
height: 1.1em;
float: right;
}
[class*=text] {
float:left;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 50%;
}
}
@media screen and (min-width: 992px){
[class*=header-icon] {
padding-top: 17px;
font-size: 1.4em;
width: 1.1em;
height: 1.1em;
float: right;
margin-right: 10px;
cursor: pointer;
}
[class*=text] {
float:left;
white-space: nowrap;
width: 50%;
cursor: auto;
}
}
scss
API リファレンス
その他のリソース
コミュニティに参加して新しいアイデアをご提案ください。