Angular Grid 列タイプ
Ignite UI for Angular Grid は、デフォルトおよび編集テンプレートの外観に基づいて、number (数値)、string (文字列)、date (日付)、boolean (ブール値)、currency (通貨) および percent (パーセント) 列のデータ型のデフォルト処理を提供します。
Angular 列タイプの例
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 { GridColumnDataTypesSampleComponent } from "./grid/grid-column-data-types-sample/grid-column-data-types-sample.component" ;
import {
IgxGridModule,
IgxTooltipModule
} from "igniteui-angular" ;
import { IgxPreventDocumentScrollModule } from "./directives/prevent-scroll.directive" ;
@NgModule ({
bootstrap : [AppComponent],
declarations : [
AppComponent,
GridColumnDataTypesSampleComponent
],
imports : [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
IgxPreventDocumentScrollModule,
IgxGridModule,
IgxTooltipModule
],
providers : [],
entryComponents : [],
schemas : []
})
export class AppModule {}
ts コピー
import { Component, OnInit } from "@angular/core" ;
import { registerLocaleData} from "@angular/common" ;
import localeBG from '@angular/common/locales/bg' ;
import localeDE from '@angular/common/locales/de' ;
import localeFR from '@angular/common/locales/fr' ;
import localeJA from '@angular/common/locales/ja' ;
@Component ({
selector : "grid-column-data-types-sample" ,
styleUrls : ["./grid-column-data-types-sample.component.scss" ],
templateUrl : "grid-column-data-types-sample.component.html"
})
export class GridColumnDataTypesSampleComponent implements OnInit {
public digitsInfoMessage: string = 'Applicable to number, currency and percent type columns' ;
public options = {
digitsInfo : '1.4-4' ,
currencyCode : ''
};
public formatOptions = this .options;
public locales = ["BG" , "EN" , "DE" , "FR" , "JA" ];
public locale = "EN" ;
public dateTimeFormats = [
{ format : "short" , eq : "'M/d/yy, h:mm a'" },
{ format : "long" , eq : "'MMMM d, y, h:mm:ss a z'" },
{ format : "full" , eq : "'EEEE, MMMM d, y, h:mm:ss a zzzz'" },
];
public dateFormats = [
{ format : "shortDate" , eq : "'M/d/yy'" },
{ format : "mediumDate" , eq : "'MMMM d, y'" },
{ format : "longDate" , eq : "'MMMM d, y'" },
{ format : "fullDate" , eq : "'EEEE, MMMM d, y'" }
];
public timeFormats = [
{ format : "shortTime" , eq : "'h:mm a'" },
{ format : "mediumTime" , eq : "'h:mm:ss a'" },
{ format : "longTime" , eq : "'h:mm:ss a z'" },
{ format : "fullTime" , eq : "'h:mm:ss a zzzz'" },
];
public timezoneFormats = ["GMT" , "UTC+9:30/ +10:30" , "UTC+0" , "UTC-6" , "UTC+1" , "UTC+3" ];
public dateTimeOptions = {
format : 'long' ,
timezone : 'UTC+0'
};
public formatDateTimeOptions = this .dateTimeOptions;
public dateOptions = {
format : 'mediumDate' ,
timezone : 'UTC+0'
};
public formatDateOptions = this .dateOptions;
public timeOptions = {
format : 'shortTime' ,
timezone : 'UTC+0'
};
public formatTimeOptions = this .timeOptions;
public currencyCodes = ["USD" , "BGN" , "EUR" , "JPY" ];
public data: any [] = [{
ProductID : 1 ,
ProductName : "Chai" ,
SupplierID : 1 ,
CategoryID : 1 ,
QuantityPerUnit : "10 boxes x 20 bags" ,
ProductImage : "https://www.infragistics.com/angular-demos-lob/assets/images/products/chai.jpg" ,
UnitPrice : 18.0000 ,
UnitsInStock : 39 ,
UnitsOnOrder : 0.030 ,
ReorderLevel : 10 ,
Discontinued : false ,
OrderDate : new Date ("2012-02-12" ),
OrderDateDelay : new Date (new Date ("2012-02-12" ).setHours(3 , 20 )),
OrderFullDate : new Date (new Date ("2012-02-12" ).setHours(3 , 20 ))
}, {
ProductID : 2 ,
ProductName : "Chang" ,
ProductImage : "https://www.infragistics.com/angular-demos-lob/assets/images/products/chang.jpg" ,
SupplierID : 1 ,
CategoryID : 1 ,
QuantityPerUnit : "24 - 12 oz bottles" ,
UnitPrice : 19.0000 ,
UnitsInStock : 17 ,
UnitsOnOrder : 0.040 ,
ReorderLevel : 25 ,
Discontinued : true ,
OrderDate : new Date ("2003-03-17" ),
OrderDateDelay : new Date (new Date ("2003-03-17" ).setHours(5 , 40 )),
OrderFullDate : new Date (new Date ("2003-03-17" ).setHours(5 , 40 ))
}, {
ProductID : 3 ,
ProductName : "Aniseed Syrup" ,
ProductImage : "https://www.infragistics.com/angular-demos-lob/assets/images/products/aniseed.jpg" ,
SupplierID : 1 ,
CategoryID : 2 ,
QuantityPerUnit : "12 - 550 ml bottles" ,
UnitPrice : 10.0000 ,
UnitsInStock : 13 ,
UnitsOnOrder : 0.070 ,
ReorderLevel : 25 ,
Discontinued : false ,
OrderDate : new Date ("2006-03-17" ),
OrderDateDelay : new Date (new Date ("2006-03-17" ).setHours(1 , 55 )),
OrderFullDate : new Date (new Date ("2006-03-17" ).setHours(1 , 55 ))
}, {
ProductID : 4 ,
ProductName : "Chef Antons Cajun Seasoning" ,
ProductImage : "https://www.infragistics.com/angular-demos-lob/assets/images/products/cajun-seasoning.jpg" ,
SupplierID : 2 ,
CategoryID : 2 ,
QuantityPerUnit : "48 - 6 oz jars" ,
UnitPrice : 22.0000 ,
UnitsInStock : 53 ,
UnitsOnOrder : 0.030 ,
ReorderLevel : 0 ,
Discontinued : false ,
OrderDate : new Date ("2016-03-17" ),
OrderDateDelay : new Date (new Date ("2016-03-17" ).setHours(11 , 11 )),
OrderFullDate : new Date (new Date ("2016-03-17" ).setHours(11 , 11 ))
}, {
ProductID : 5 ,
ProductName : "Chef Antons Gumbo Mix" ,
ProductImage : "https://www.infragistics.com/angular-demos-lob/assets/images/products/chef-antons-gumbo-mix.jpg" ,
SupplierID : 2 ,
CategoryID : 2 ,
QuantityPerUnit : "36 boxes" ,
UnitPrice : 21.3500 ,
UnitsInStock : 0 ,
UnitsOnOrder : 0.030 ,
ReorderLevel : 0 ,
Discontinued : true ,
OrderDate : new Date ("2011-11-11" ),
OrderDateDelay : null ,
OrderFullDate : null
}, {
ProductID : 6 ,
ProductName : "Grandmas Boysenberry Spread" ,
ProductImage : "https://www.infragistics.com/angular-demos-lob/assets/images/products/grandmas-boysenberry-spread.jpg" ,
SupplierID : 3 ,
CategoryID : 2 ,
QuantityPerUnit : "12 - 8 oz jars" ,
UnitPrice : 25.0000 ,
UnitsInStock : 0 ,
UnitsOnOrder : 0.030 ,
ReorderLevel : 25 ,
Discontinued : false ,
OrderDate : new Date ("2017-12-17" ),
OrderDateDelay : new Date (new Date ("2017-12-17" ).setHours(2 , 15 )),
OrderFullDate : new Date (new Date ("2017-12-17" ).setHours(2 , 15 ))
}, {
ProductID : 7 ,
ProductName : "Uncle Bobs Organic Dried Pears" ,
ProductImage : "https://www.infragistics.com/angular-demos-lob/assets/images/products/uncle-bobs-organic-dried-pears.jpg" ,
SupplierID : 3 ,
CategoryID : 7 ,
QuantityPerUnit : "12 - 1 lb pkgs." ,
UnitPrice : 30.0000 ,
UnitsInStock : 150 ,
UnitsOnOrder : 0.030 ,
ReorderLevel : 10 ,
Discontinued : false ,
OrderDate : new Date ("2016-07-17" ),
OrderDateDelay : undefined ,
OrderFullDate : new Date (new Date ("2016-07-17" ).setHours(1 , 55 ))
}, {
ProductID : 8 ,
ProductName : "Northwoods Cranberry Sauce" ,
ProductImage : "https://www.infragistics.com/angular-demos-lob/assets/images/products/cranberry-sauce.jpg" ,
SupplierID : 3 ,
CategoryID : 2 ,
QuantityPerUnit : "12 - 12 oz jars" ,
UnitPrice : 40.0000 ,
UnitsInStock : 6 ,
UnitsOnOrder : 0.030 ,
ReorderLevel : 0 ,
Discontinued : false ,
OrderDate : new Date ("2018-01-17" ),
OrderDateDelay : null ,
OrderFullDate : new Date (new Date ("2018-01-17" ).setHours(1 , 55 ))
}, {
ProductID : 9 ,
ProductName : "Mishi Kobe Niku" ,
ProductImage : "https://www.infragistics.com/angular-demos-lob/assets/images/products/mishi-kobe-niku.jpg" ,
SupplierID : 4 ,
CategoryID : 6 ,
QuantityPerUnit : "18 - 500 g pkgs." ,
UnitPrice : 97.0000 ,
UnitsInStock : 29 ,
UnitsOnOrder : 0.030 ,
ReorderLevel : 0 ,
Discontinued : true ,
OrderDate : new Date ("2010-02-17" ),
OrderDateDelay : new Date (new Date ("2010-02-17" ).setHours(8 , 10 )),
OrderFullDate : new Date (new Date ("2010-02-17" ).setHours(8 , 10 ))
}
];
private regEx = new RegExp ('^[0-9]+.[0-9]+-[0-9]$' )
constructor ( ) {
}
public ngOnInit(): void {
registerLocaleData(localeBG);
registerLocaleData(localeDE);
registerLocaleData(localeFR);
registerLocaleData(localeJA);
}
public reset ( ) {
this .options.digitsInfo = '1.4-4' ;
this .formatOptions = Object .assign({}, this .formatOptions, this .options);
}
public clearCode (event ) {
event.preventDefault();
this .options.currencyCode = '' ;
this .formatOptions = Object .assign({}, this .formatOptions, this .options);
}
public modelChange ( ) {
if (this .options.digitsInfo.match(this .regEx)) {
if (Number (this .options.digitsInfo.substr(2 , 1 )) > Number (this .options.digitsInfo.substr(4 , 1 ))) {
this .digitsInfoMessage = 'The minimum number of digits after fraction (x) is higher than the maximum (x).' ;
} else {
this .digitsInfoMessage = 'Applicable to number, currency and percent type columns' ;
this .formatOptions = Object .assign({}, this .formatOptions, this .options);
}
}
}
public selectionChanging (event ) {
this .dateTimeOptions.format = event.newSelection.value;
this .formatDateTimeOptions = Object .assign({}, this .formatDateTimeOptions, this .dateTimeOptions);
}
public selectionDateChanging (event ) {
this .dateOptions.format = event.newSelection.value;
this .formatDateOptions = Object .assign({}, this .formatDateOptions, this .dateOptions);
}
public selectionTimeChanging (event ) {
this .timeOptions.format = event.newSelection.value;
this .formatTimeOptions = Object .assign({}, this .formatTimeOptions, this .timeOptions);
}
public timezoneSelectionChanging (event ) {
this .dateTimeOptions.timezone = event.newSelection.value;
this .formatDateTimeOptions = Object .assign({}, this .formatDateTimeOptions, this .dateTimeOptions);
}
public currencySelectionChanging (event ) {
this .options.currencyCode = event.newSelection.value;
this .formatOptions = Object .assign({}, this .formatOptions, this .options);
}
public warningClass ( ) {
if (!this .digitsInfoMessage.startsWith('Applicable' )) return 'warning' ;
}
}
ts コピー <div class ="wrapper" >
<span class ="location-wrapper" >
<igx-select #select [(ngModel )]="locale" >
<igx-prefix class ="ellipsis" > Locale: </igx-prefix >
<igx-select-item *ngFor ="let locale of locales" [value ]="locale" >
{{ locale }}
</igx-select-item >
<igx-hint > Applicable to date, number, currency and percent type columns</igx-hint >
</igx-select >
<igx-select #select [(ngModel )]="dateTimeOptions.format" (selectionChanging )="selectionChanging($event)" >
<igx-prefix class ="ellipsis" > DateTime format: </igx-prefix >
<igx-select-item *ngFor ="let dateFormat of dateTimeFormats" [value ]="dateFormat.format"
[text ]="dateFormat.format + ' ---> ' + dateFormat.eq" >
{{ dateFormat.format }}
</igx-select-item >
<igx-hint > Applied to 'dateTime' type column only</igx-hint >
</igx-select >
<igx-select #select [(ngModel )]="dateOptions.format" (selectionChanging )="selectionDateChanging($event)" >
<igx-prefix class ="ellipsis" > Date format: </igx-prefix >
<igx-select-item *ngFor ="let dateFormat of dateFormats" [value ]="dateFormat.format"
[text ]="dateFormat.format + ' ---> ' + dateFormat.eq" >
{{ dateFormat.format }}
</igx-select-item >
<igx-hint > Applied to 'date' type column only</igx-hint >
</igx-select >
<igx-select #select [(ngModel )]="timeOptions.format" (selectionChanging )="selectionTimeChanging($event)" >
<igx-prefix class ="ellipsis" > Time format: </igx-prefix >
<igx-select-item *ngFor ="let timeFormat of timeFormats" [value ]="timeFormat.format"
[text ]="timeFormat.format + ' ---> ' + timeFormat.eq" >
{{ timeFormat.format }}
</igx-select-item >
<igx-hint > Applied to 'time' type column only</igx-hint >
</igx-select >
<igx-select #select [(ngModel )]="dateTimeOptions.timezone" (selectionChanging )="timezoneSelectionChanging($event)" >
<igx-prefix class ="ellipsis" > Timezone: </igx-prefix >
<igx-select-item *ngFor ="let timezone of timezoneFormats" [value ]="timezone" [text ]="timezone" >
{{ timezone }}
</igx-select-item >
<igx-hint > Applicable to dateTime type columns only</igx-hint >
</igx-select >
<igx-select #select [(ngModel )]="options.currencyCode" (selectionChanging )="currencySelectionChanging($event)" >
<igx-prefix class ="ellipsis" > Currency Code: </igx-prefix >
<igx-select-item *ngFor ="let currencyCode of currencyCodes" [value ]="currencyCode" >
{{ currencyCode }}
</igx-select-item >
<igx-hint > Applicable to currency type columns</igx-hint >
<igx-suffix >
<igx-icon class ="prefixIcon" *ngIf ="options.currencyCode.length > 0" (click )="clearCode($event)" > clear
</igx-icon >
</igx-suffix >
</igx-select >
<br />
<igx-input-group type ="search" class ="searchInputGroup" >
<igx-prefix class ="ellipsis" >
<div #target ="tooltipTarget" [igxTooltipTarget ]="tooltipRef" [showDelay ]="0" [hideDelay ]="0" > Set digits
info
</div >
<div #tooltipRef ="tooltip" igxTooltip >
<span style ="width: 300px" > Decimal representation options, specified by a string in the following
format: minIntegerDigits.minFractionDigits-maxFractionDigits</span >
</div >
</igx-prefix >
<input name ="info" igxInput placeholder ="Digits info" [(ngModel )]="options.digitsInfo"
(ngModelChange )="modelChange()" />
<igx-suffix >
<igx-icon class ="prefixIcon" *ngIf ="options.digitsInfo.length > 0" (click )="reset()" > clear
</igx-icon >
</igx-suffix >
<igx-hint [ngClass ]="warningClass()" position ="start" > {{ digitsInfoMessage }}</igx-hint >
</igx-input-group >
</span >
<span class ="grid-wrapper" >
<igx-grid [igxPreventDocumentScroll ]="true" #grid1 [data ]="data" [allowFiltering ]="true" [locale ]="locale"
[filterMode ]="'excelStyleFilter'" [autoGenerate ]="false" [height ]="null" displayDensity ="compact" >
<igx-column field ="ProductName" [width ]="'120px'" header ="Prod. Name" [sortable ]="true" [hasSummary ]="true"
[editable ]="true" [dataType ]="'string'" [resizable ]="true" >
</igx-column >
<igx-column field ="ProductImage" [width ]="'60px'" header ="Image" [dataType ]="'image'" [resizable ]="true" >
</igx-column >
<igx-column field ="UnitPrice" [width ]="'100px'" header ="Unit Price" [sortable ]="true" [hasSummary ]="true" [editable ]="true"
[pipeArgs ]="formatOptions" [dataType ]="'number'" [resizable ]="true" >
</igx-column >
<igx-column field ="OrderFullDate" [width ]="'250px'" header ="Order Full Date" [sortable ]="true" [hasSummary ]="true" [editable ]="true"
[pipeArgs ]="formatDateTimeOptions" [dataType ]="'dateTime'" [resizable ]="true" >
</igx-column >
<igx-column field ="OrderDate" [width ]="'160px'" header ="Order Date" [sortable ]="true" [hasSummary ]="true" [editable ]="true"
[pipeArgs ]="formatDateOptions" [dataType ]="'date'" [resizable ]="true" >
</igx-column >
<igx-column field ="OrderDateDelay" [width ]="'120px'" header ="Order Time" [sortable ]="true" [hasSummary ]="true" [editable ]="true"
[pipeArgs ]="formatTimeOptions" [dataType ]="'time'" [resizable ]="true" >
</igx-column >
<igx-column field ="UnitsInStock" [width ]="'120px'" header ="Stock Value" [sortable ]="true" [hasSummary ]="true"
[editable ]="true" [pipeArgs ]="formatOptions" [dataType ]="'currency'" [resizable ]="true" >
</igx-column >
<igx-column field ="UnitsOnOrder" [width ]="'120px'" header ="% Change" [sortable ]="true" [hasSummary ]="true"
[editable ]="true" [pipeArgs ]="formatOptions" [dataType ]="'percent'" [resizable ]="true" >
</igx-column >
<igx-column field ="Discontinued" [width ]="'120px'" header ="Discontinued" [sortable ]="true" [hasSummary ]="true"
[editable ]="true" [dataType ]="'boolean'" [resizable ]="true" >
</igx-column >
</igx-grid >
</span >
</div >
html コピー @use '../../../variables' as *;
.grid-wrapper {
margin : 15px ;
}
.location-wrapper {
min-width : 200px ;
margin : 20px ;
}
.wrapper {
display : grid;
grid-template-columns : 1 fr 3 fr;
}
.ellipsis {
@include ellipsis();
}
.warning {
color :red;
}
scss コピー
このサンプルが気に入りましたか? 完全な Ignite UI for Angularツールキットにアクセスして、すばやく独自のアプリの作成を開始します。無料でダウンロードできます。
デフォルトのテンプレート
データ型固有のテンプレートを有効にする場合、列の dataType
入力を設定する必要があります。設定しない場合、列は文字列の列として処理されます (これは列 dataType のデフォルト値であるためです)。次に各型のデフォルト テンプレートについて説明します。
String (文字列)
この列 dataType
はセル値の外観または書式を変更しません。
Number (数値)
dataType
が number に設定されている場合、セル値はアプリケーションまたはグリッドの locale
設定に基づいて書式設定され、pipeArgs
プロパティが指定されている場合にも同じように設定されます。数値書式はそれらに基づいて変更されます。たとえば、以下を変更します:
小数点後の桁数。
,
または .
の少数桁の区切り文字
public options = {
digitsInfo : '1.4-4' ,
};
public formatOptions = this .options;
ts
<igx-column [pipeArgs ]="formatOptions" [dataType ]="'number'" >
</igx-column >
html
DateTime、Date と Time
日付部分の外観は、locale
の形式または pipeArgs
入力に基づいて設定されます (例: 日、月、年)。Pipe 引数はカスタム日付書式 またはタイムゾーン を指定するために使用できます。
format - 日付の書式設定のデフォルト値は 'mediumDate' です。その他の利用可能なオプションは 'short'、'long'、'shortDate'、'fullDate'、'longTime'、'fullTime' などです。以下は利用可能なすべての定義済みの書式オプション の完全なリストです。
timezone - ユーザーのローカル システム タイムゾーンがデフォルト値です。タイムゾーン オフセットまたは標準の UTC/GMT または米国本土のタイムゾーンの略語も渡すことができます。世界の任意の場所の対応する時間を表示するさまざまなタイムゾーンの例:
public formatDateOptions = {
format : 'longDate' ,
timezone : 'GMT'
};
public formatOptions = this .options;
ts
<igx-column [pipeArgs ]="formatDateOptions" [dataType ]="'date'" >
</igx-column >
html
利用可能なタイムゾーン:
タイムゾーン
値
Alpha Time Zone
‘UTC+1’
Australian Central Time
‘UTC+9:30/ +10:30’
Arabia Standard Time
‘UTC+3’
Central Standard Time
‘UTC-6’
China Standard Time
‘UTC+8’
Delta Time Zone
‘UTC+4’
Greenwich Mean Time
‘UTC+0’
Gulf Standard Time
‘UTC+4’
Hawaii Standard Time
‘UTC-10’
India Standard Time
‘UTC+4’
Grid は、Date オブジェクト 、数値 (ミリ秒) または ISO 日付/時刻文字列 の日付値を受け取ります。このセクションは、カスタム表示書式を構成する方法 を示します。
サンプルでは、特定の列タイプで使用可能な書式を紹介するために、さまざまな書式設定オプションを指定しています。たとえば、以下は日付オブジェクトの time 部分の書式設定オプションのサンプルです。
public timeFormats = [
{ format : 'shortTime' , eq : 'h:mm a' },
{ format : 'mediumTime' , eq : 'h:mm:ss a' },
{ format : 'longTime' , eq : 'h:mm:ss a z' },
{ format : 'fullTime' , eq : 'h:mm:ss a zzzz' },
];
ts
セル編集
列タイプに基づくセル編集に関しては、別のエディターが表示されます。
フィルタリング
クイック フィルタリング / Excel スタイル フィルタリングに関しては、上記と同じエディターが使用されます。これらは、各タイプが公開する次のフィルタリング オペランドです。
dateTime and date - Equals、Does Not Equal、Before、After、Today、Yesterday、This Month、Last Month、Next Month、This Year、Last Year、Next Year、Empty、Not Empty、Null、Not Null;
time - At、Not At、Before、After、At or Before、At or After、Empty、Not Empty、Null、Not Null;
集計
使用可能な集計オペランドは、Count 、Earliest (date/time)、および Latest (date/time) になります。
ソート
Time タイプの列は、オブジェクトの時間部分に基づいてソートされます。分/秒は無視されます。Date タイプの列は、日付部分に基づいてソートされ、時間部分は無視されます。DateTime 列は、日付に基づいてソートされます。
Boolean (ブール値)
デフォルトのテンプレートは、ブール値の可視化にマテリアル アイコンを使用します。false 値には 'clear' アイコン、true 値には 'check' アイコンを使用します。編集テンプレートは igx-checkbox コンポーネントを使用しています。
<igx-column [dataType ]="'boolean'" >
</igx-column >
html
Currency (通貨)
デフォルトのテンプレート
デフォルトのテンプレートには、プレフィックスまたはサフィックスが付いた通貨記号を含む数値を表示します。通貨記号の位置と数値の書式設定は、提供された Application LOCALE_ID
または Grid の locale
に基づいています。
LOCALE_ID を使用する場合
import { LOCALE_ID } from '@angular/core' ;
...
@Component ({
selector : 'app-component.sample' ,
templateUrl : 'grid-component.sample.html' ,
providers : [{provide : LOCALE_ID, useValue : 'fr-FR' }]
})
ts
グリッドの locale を使用する場合
<igx-grid [locale ]="'fr-FR'" [data ]="data" >
</igx-grid >
html
pipeArgs
入力を使用することにより、エンドユーザーは小数点 、currencyCode および display によって数値書式をカスタマイズできます。
public options = {
digitsInfo : '3.4-4' ,
currencyCode : 'USD' ,
display : 'symbol-narrow'
};
public formatOptions = this .options;
ts
<igx-column field ="UnitsInStock"
[pipeArgs ]="formatOptions"
[dataType ]="'currency'" >
</igx-column >
html
パラメーター
説明
digitsInfo
通貨値の 10 進数表現を表します
currencyCode
ISO 4217 通貨コード
display*
省略記号または記号で値を表示します
*display - デフォルトの en-US ロケールの場合、USD コードは省略記号 ($) または記号 (US$) で表すことができます。
セルの値を編集すると、通貨記号 がサフィックスまたはプレフィックスとして表示されます。詳細については、公式のセル編集トピック を参照してください。
上/下矢印キーを使用する場合、値は digitsInfo-minFractionDigits (小数点以下の最小桁数。デフォルトは 0 です。) に基づいてステップで増減します。
Percent (パーセント)
デフォルトのテンプレートは、基になる数値に相当するパーセントを表示します。表示されるセル値は、'100' の表示ファクタで乗算された結果です。たとえば、デフォルトのファクタは 100 で、セルに渡される値は 0.123 であるため、表示されるセル値は 12.3% になります。
セル編集の場合、値はデータ ソース値と同じになります。表示ファクタは '1' です。セルを編集すると、パーセント値のプレビューがサフィックス要素として表示されます。たとえば、'0.0547' の編集中にプレビュー要素に '5.47%' が表示されます。
public options = {
digitsInfo : '2.2-3'
};
public formatPercentOptions = this .options;
ts
<igx-column field ="UnitsInStock"
[pipeArgs ]="formatPercentOptions"
[dataType ]="'percent'" >
</igx-column >
html
上/下矢印キーを使用する場合、値は digitsInfo-minFractionDigits (小数点以下の最小桁数。デフォルトは 0 です。) に基づいてステップで増減します。
画像
デフォルトのテンプレートは、デフォルの画像テンプレートへの画像ソースとしてデータからの値を使用しています。デフォルトの画像テンプレートは、画像ファイルの名前を抽出し、アクセシビリティ要件を満たすために画像の alt
属性として設定します。表示されるセル サイズは描画される画像のサイズに合わせて調整されるため、大きな画像も描画され、グリッド行は画像列の画像と同じ大きさになることに注意してください。画像タイプの列では、フィルタリング、ソート、およびグループ化はデフォルトでオフになっています。それらを有効にしたい場合は、データ操作を実行するカスタム ストラテジを提供する必要があります。
<igx-column [dataType ]="'image'" >
</igx-column >
html
列を自動生成する 場合、グリッドは最初のデータ レコードの値を分析します。値が文字列型で、画像拡張子 (gif、jpg、jpeg、tiff、png、webp、bmp) で終わる URL のパターンと一致する場合、列は自動的に dataType === GridColumnDataType.Image
としてマークされ、デフォルトの画像テンプレートが描画されます。
デフォルトの編集テンプレート
Grid 編集トピック の編集テンプレート部分を参照してください。
カスタム編集テンプレートとフォーマッタ
カスタム テンプレートと列フォーマッタの定義は、列データ型セットより常に優先されます。
カスタム テンプレート
<igx-grid #grid1 [data ]="data | async" [autoGenerate ]="false" >
<igx-column [field ]="'UnitsInStock'" [dataType ]="'currency'" [pipeArgs ]="formatOptions" [editable ]="true" >
<ng-template igxCellEditor let-value >
{{ value | currency:'USD':'symbol':'1.0-0'}}
</ng-template >
</igx-column >
</igx-grid >
html
列フォーマッタ
public formatCurrency (value: number ) {
return `Dollar sign ${value.toFixed(0 )} ` ;
}
public init (column: IgxColumnComponent ) {
switch (column.field) {
case 'UnitsInStock' :
column.formatter = this .formatCurrency;
break ;
default :
return ;
}
ts
API リファレンス
その他のリソース