このコントロールは非推奨であり、Grid に置き換えられていることに注意してください。そのため、そのコントロールに移行することをお勧めします。これは新しい機能を受け取ることはなく、バグ修正は優先されません。コードベースをデータ グリッドに移行する際のヘルプや質問については、サポートにお問い合わせください。
Web Components 列集計
Ignite UI for Web Components Data Table / Data Grid は、列集計をサポートしています。エンドユーザーは、グリッドに表示されるデータ量が多い場合などでデータ集計の表示を必要とすることがあります。エンドユーザーは、特定の列のデータから追加情報を取得することもできます。これを実現するには集計が役立ちます。集計を有効にするには、summaryScope
プロパティを設定します。
Web Components 列集計の例
export class DataGridSharedData {
public static getEmployees(count?: number ): any [] {
if (count === undefined ) {
count = 250 ;
}
const employees: any [] = [];
let maleCount: number = 0 ;
let femaleCount: number = 0 ;
for (let i = 0 ; i < count; i++) {
const age: number = Math .round(this .getRandomNumber(20 , 40 ));
const gender: string = this .getRandomGender();
const firstName: string = this .getRandomNameFirst(gender);
const lastName: string = this .getRandomNameLast();
const street: string = this .getRandomStreet();
const country: string = this .getRandomItem(this .countries);
const city: string = this .getRandomCity(country);
const generation = Math .floor(age / 10 ) * 10 + "s" ;
const email: string = firstName.toLowerCase() + "@" + this .getRandomItem(this .emails);
const website: string = firstName.toLowerCase() + "-" + this .getRandomItem(this .websites);
let photoPath: any ;
if (gender === "male" ) {
maleCount++;
if (maleCount > 26 ) {
maleCount = 1 ;
}
photoPath = this .getPhotoMale(maleCount);
}
else {
femaleCount++;
if (femaleCount > 24 ) {
femaleCount = 1 ;
}
photoPath = this .getPhotoFemale(femaleCount);
}
let person: any = {};
person.Address = street + "," + city;
person.Age = age;
person.Birthday = this .getBirthday(age);
person.City = city;
person.Country = country;
person.CountryFlag = this .getCountryFlag(country);
person.Email = email;
person.FirstName = firstName;
person.Gender = this .getGenderPhoto(gender);
person.Generation = generation;
person.ID = this .pad(i + 1 , 5 );
person.LastName = lastName;
person.Name = firstName + " " + lastName;
person.Phone = this .getRandomPhone();
person.Photo = photoPath;
person.Street = street;
person.Salary = this .getRandomNumber(40 , 200 ) * 1000 ;
person.Sales = this .getRandomNumber(200 , 980 ) * 1000 ;
person.Website = website;
person.Productivity = this .getProductivity();
if (person.Salary < 50000 ) {
person.Income = "Low" ;
} else if (person.Salary < 100000 ) {
person.Income = "Average" ;
} else {
person.Income = "High" ;
}
employees.push(person);
}
return employees;
}
public static getProductivity(weekCount?: number ): any [] {
if (weekCount === undefined ) {
weekCount = 52 ;
}
const productivity: any [] = [];
for (let w = 0 ; w < weekCount; w++) {
const value = this .getRandomNumber(-50 , 50 );
productivity.push({Value : value, Week : w});
}
return productivity;
}
public static getSales(count?: number ): any [] {
if (count === undefined ) {
count = 250 ;
}
const names: string [] = [
"Intel CPU" , "AMD CPU" ,
"Intel Motherboard" , "AMD Motherboard" , "NVIDIA Motherboard" ,
"NVIDIA GPU" , "GIGABYTE GPU" , "Asus GPU" , "AMD GPU" , "MSI GPU" ,
"Corsair Memory" , "Patriot Memory" , "Skill Memory" ,
"Samsung HDD" , "WD HDD" , "Seagate HDD" , "Intel HDD" ,
"Samsung SSD" , "WD SSD" , "Seagate SSD" , "Intel SSD" ,
"Samsung Monitor" , "Asus Monitor" , "LG Monitor" , "HP Monitor" ];
const countries: string [] = ["USA" , "UK" , "France" , "Canada" , "Poland" , "Japan" , "Germany" ];
const status: string [] = ["Packing" , "Shipped" , "Delivered" ];
const sales: any [] = [];
for (let i = 0 ; i < count; i++) {
const price = this .getRandomNumber(100 , 900 );
const items = this .getRandomNumber(10 , 80 );
const value = price * items;
const margin = this .getRandomNumber(3 , 10 );
const profit = Math .round((price * margin / 100 ) * items);
const country = this .getRandomItem(countries);
sales.push({
BundlePrice : price,
ProductPrice : price,
Margin : margin,
OrderDate : this .getRandomDate(new Date (2012 , 0 , 1 ), new Date ()),
OrderItems : items,
OrderValue : value,
ProductID : 1001 + i,
ProductName : this .getRandomItem(names),
Profit : profit,
Countries : country,
CountryFlag : this .getCountryFlag(country),
Status : this .getRandomItem(status)
});
}
return sales;
}
public static getHouses(count?: number ): any [] {
if (count === undefined ) {
count = 250 ;
}
const houses: any [] = [];
const property: string [] = [ "Townhouse" , "Single" , "Condo" , "Villa" ];
const emails: string [] = [ "estates.com" , "remax.com" , "zillow.com" , "realtor.com" , "coldwell.com" ];
const countries: string [] = ["USA" , "UK" , "France" , "Canada" , "Poland" , "Japan" , "Germany" ];
for (let i = 0 ; i < count; i++) {
const year: number = this .getRandomNumber(1950 , 2015 );
const age: number = 2020 - year;
const gender: string = this .getRandomGender();
const firstName: string = this .getRandomNameFirst(gender);
const lastName: string = this .getRandomNameLast();
const initials = firstName.substr(0 , 1 ).toLowerCase();
const email: string = initials + lastName.toLowerCase() + "@" + this .getRandomItem(emails);
const street: string = this .getRandomStreet();
const country: string = this .getRandomItem(countries);
const city: string = this .getRandomCity(country);
houses.push({
Address : street + "," + city,
Age : age,
Agent : firstName + " " + lastName,
Area : this .getRandomNumber(50 , 300 ),
Baths : this .getRandomNumber(1 , 3 ),
Built : year,
City : city,
Country : country,
CountryFlag : this .getCountryFlag(country),
Email : email,
ID : this .pad(i + 1 , 5 ),
Phone : this .getRandomPhone(),
Price : this .getRandomNumber(210 , 900 ) * 1000 ,
Property : this .getRandomItem(property),
Rooms : this .getRandomNumber(2 , 5 ),
SaleDate : this .getRandomDate(new Date (2015 , 0 , 1 ), new Date ()),
Street : street,
});
}
return houses;
}
private static websites: string [] = [ ".com" , ".gov" , ".edu" , ".org" ];
private static emails: string [] = [ "gmail.com" , "yahoo.com" , "twitter.com" ];
private static genders: string [] = ["male" , "female" ];
private static maleNames: string [] = ["Kyle" , "Oscar" , "Ralph" , "Mike" , "Bill" , "Frank" , "Howard" , "Jack" , "Larry" , "Pete" , "Steve" , "Vince" , "Mark" , "Alex" , "Max" , "Brian" , "Chris" , "Andrew" , "Martin" , "Mike" , "Steve" , "Glenn" , "Bruce" ];
private static femaleNames: string [] = ["Gina" , "Irene" , "Katie" , "Brenda" , "Casey" , "Fiona" , "Holly" , "Kate" , "Liz" , "Pamela" , "Nelly" , "Marisa" , "Monica" , "Anna" , "Jessica" , "Sofia" , "Isabella" , "Margo" , "Jane" , "Audrey" , "Sally" , "Melanie" , "Greta" , "Aurora" , "Sally" ];
private static lastNames: string [] = ["Adams" , "Crowley" , "Ellis" , "Martinez" , "Irvine" , "Maxwell" , "Clark" , "Owens" , "Rooney" , "Lincoln" , "Thomas" , "Spacey" , "MOrgan" , "King" , "Newton" , "Fitzgerald" , "Holmes" , "Jefferson" , "Landry" , "Berry" , "Perez" , "Spencer" , "Starr" , "Carter" , "Edwards" , "Stark" , "Johnson" , "Fitz" , "Chief" , "Blanc" , "Perry" , "Stone" , "Williams" , "Lane" , "Jobs" , "Adams" , "Power" , "Tesla" ];
private static countries: string [] = ["USA" , "UK" , "France" , "Canada" , "Poland" ];
private static citiesUS: string [] = ["New York" , "Los Angeles" , "Miami" , "San Francisco" , "San Diego" , "Las Vegas" ];
private static citiesUK: string [] = ["London" , "Liverpool" , "Manchester" ];
private static citiesFR: string [] = ["Paris" , "Marseille" , "Lyon" ];
private static citiesCA: string [] = ["Toronto" , "Vancouver" , "Montreal" ];
private static citiesPL: string [] = ["Krakow" , "Warsaw" , "Wroclaw" , "Gdansk" ];
private static citiesJP: string [] = ["Tokyo" , "Osaka" , "Kyoto" , "Yokohama" ];
private static citiesGR: string [] = ["Berlin" , "Bonn" , "Cologne" , "Munich" , "Hamburg" ];
private static roadSuffixes: string [] = ["Road" , "Street" , "Way" ];
private static roadNames: string [] = ["Main" , "Garden" , "Broad" , "Oak" , "Cedar" , "Park" , "Pine" , "Elm" , "Market" , "Hill" ];
private static getRandomNumber(min: number , max : number ): number {
return Math .round(min + Math .random() * (max - min));
}
private static getRandomItem(array: any []): any {
const index = Math .round(this .getRandomNumber(0 , array.length - 1 ));
return array[index];
}
private static getRandomDate (start: Date , end: Date ) {
return new Date (start.getTime() + Math .random() * (end.getTime() - start.getTime()));
}
private static getRandomPhone(): string {
const phoneCode = this .getRandomNumber(100 , 900 );
const phoneNum1 = this .getRandomNumber(100 , 900 );
const phoneNum2 = this .getRandomNumber(1000 , 9000 );
const phone = phoneCode + "-" + phoneNum1 + "-" + phoneNum2;
return phone;
}
private static getRandomGender(): string {
return this .getRandomItem(this .genders);
}
private static getRandomNameLast(): string {
return this .getRandomItem(this .lastNames);
}
private static getRandomNameFirst(gender: string ): string {
if (gender === "male" ) {
return this .getRandomItem(this .maleNames);
}
else {
return this .getRandomItem(this .femaleNames);
}
}
private static getRandomCity(country: string ): string {
if (country === "Canada" ) {
return this .getRandomItem(this .citiesCA);
} else if (country === "France" ) {
return this .getRandomItem(this .citiesFR);
} else if (country === "Poland" ) {
return this .getRandomItem(this .citiesPL);
} else if (country === "USA" ) {
return this .getRandomItem(this .citiesUS);
} else if (country === "Japan" ) {
return this .getRandomItem(this .citiesJP);
} else if (country === "Germany" ) {
return this .getRandomItem(this .citiesGR);
} else {
return this .getRandomItem(this .citiesUK);
}
}
private static getRandomStreet(): string {
const num = Math .round(this .getRandomNumber(100 , 300 )).toString();
const road = this .getRandomItem(this .roadNames);
const suffix = this .getRandomItem(this .roadSuffixes);
return num + " " + road + " " + suffix;
}
private static getBirthday(age: number ): Date {
const today: Date = new Date ();
const year: number = today.getFullYear() - age;
const month: number = this .getRandomNumber(0 , 8 );
const day: number = this .getRandomNumber(10 , 27 );
return new Date (year, month, day);
}
private static getPhotoMale(id: number ): string {
return 'https://static.infragistics.com/xplatform/images/people//GUY' + this .pad(id, 2 ) + '.png' ;
}
private static getPhotoFemale(id: number ): string {
return 'https://static.infragistics.com/xplatform/images/people/GIRL' + this .pad(id, 2 ) + '.png' ;
}
private static getGenderPhoto(gender: string ): string {
return 'https://static.infragistics.com/xplatform/images/genders/' + gender + '.png' ;
}
private static getCountryFlag(country: string ): string {
return 'https://static.infragistics.com/xplatform/images/flags/' + country + '.png' ;
}
private static pad (num: number , size: number ) {
let s = num + "" ;
while (s.length < size) {
s = "0" + s;
}
return s;
}
}
ts コピー import { IgcDataGridModule } from 'igniteui-webcomponents-grids' ;
import { IgcGridColumnOptionsModule } from 'igniteui-webcomponents-grids' ;
import { IgcDataGridComponent } from 'igniteui-webcomponents-grids' ;
import { ModuleManager, IgcProvideCalculatorEventArgs } from 'igniteui-webcomponents-core' ;
import { DataGridSharedData } from './DataGridSharedData' ;
import { IgcColumnGroupDescription } from 'igniteui-webcomponents-grids' ;
import { IgcColumnSummaryDescription } from 'igniteui-webcomponents-grids'
import { DataSourceSummaryOperand, SummaryCalculator, DefaultSummaryResult, IDataSource, ISummaryResult } from 'igniteui-webcomponents-core' ;
ModuleManager.register(
IgcDataGridModule,
IgcGridColumnOptionsModule
);
export class DataGridColumnSummaries {
private grid: IgcDataGridComponent;
constructor ( ) {
this .onSummaryScopeChanging = this .onSummaryScopeChanging.bind(this );
this .onGroupSummaryDisplayModeChanging = this .onGroupSummaryDisplayModeChanging.bind(this );
this .grid = document .getElementById('grid' ) as IgcDataGridComponent;
this .grid.dataSource = DataGridSharedData.getSales();
document .getElementById('onSummaryScopeChanging' )!.addEventListener('change' , this .onSummaryScopeChanging);
document .getElementById('onGroupSummaryDisplayModeChanging' )!.addEventListener('change' , this .onGroupSummaryDisplayModeChanging);
this .onLoad();
}
onSummaryScopeChanging = (e: any ) => {
this .grid.summaryScope = e.target.value;
}
onGroupSummaryDisplayModeChanging = (e: any ) => {
this .grid.groupSummaryDisplayMode = e.target.value;
}
onLoad ( ) {
const productGroup = new IgcColumnGroupDescription();
productGroup.field = 'ProductName' ;
productGroup.displayName = 'ProductName' ;
this .grid.groupDescriptions.add(productGroup);
const productCount = new IgcColumnSummaryDescription();
productCount.field = 'ProductName' ;
productCount.operand = DataSourceSummaryOperand.Count;
this .grid.summaryDescriptions.add(productCount);
const priceMin = new IgcColumnSummaryDescription();
priceMin.field = 'BundlePrice' ;
priceMin.operand = DataSourceSummaryOperand.Min;
priceMin.formatOverride = new Intl .NumberFormat('en-EN' , { style : 'currency' , currency : 'USD' , minimumFractionDigits : 0 , maximumFractionDigits : 0 });
this .grid.summaryDescriptions.add(priceMin);
const priceMax = new IgcColumnSummaryDescription();
priceMax.field = 'BundlePrice' ;
priceMax.operand = DataSourceSummaryOperand.Max;
priceMax.formatOverride = new Intl .NumberFormat('en-EN' , { style : 'currency' , currency : 'USD' , minimumFractionDigits : 0 , maximumFractionDigits : 0 });
this .grid.summaryDescriptions.add(priceMax);
const orderSum = new IgcColumnSummaryDescription();
orderSum.field = 'OrderItems' ;
orderSum.operand = DataSourceSummaryOperand.Sum;
this .grid.summaryDescriptions.add(orderSum);
const orderValueSum = new IgcColumnSummaryDescription();
orderValueSum.field = 'OrderValue' ;
orderValueSum.operand = DataSourceSummaryOperand.Sum;
orderValueSum.formatOverride = new Intl .NumberFormat('en-EN' , { style : 'currency' , currency : 'USD' , minimumFractionDigits : 0 , maximumFractionDigits : 0 });
this .grid.summaryDescriptions.add(orderValueSum);
const orderValueAvg = new IgcColumnSummaryDescription();
orderValueAvg.field = 'OrderValue' ;
orderValueAvg.operand = DataSourceSummaryOperand.Average;
orderValueAvg.formatOverride = new Intl .NumberFormat('en-EN' , { style : 'currency' , currency : 'USD' , minimumFractionDigits : 0 , maximumFractionDigits : 0 });
this .grid.summaryDescriptions.add(orderValueAvg);
const orderDateMin = new IgcColumnSummaryDescription();
orderDateMin.field = 'OrderDate' ;
orderDateMin.operand = DataSourceSummaryOperand.Min;
orderDateMin.calculatorDisplayName = 'First'
orderDateMin.formatOverride = new Intl .DateTimeFormat('en-EN' );
this .grid.summaryDescriptions.add(orderDateMin);
const orderDateMax = new IgcColumnSummaryDescription();
orderDateMax.field = 'OrderDate' ;
orderDateMax.operand = DataSourceSummaryOperand.Max;
orderDateMax.calculatorDisplayName = 'Last'
orderDateMax.formatOverride = new Intl .DateTimeFormat('en-EN' );
this .grid.summaryDescriptions.add(orderDateMax);
const sum1 = new IgcColumnSummaryDescription();
sum1.field = 'Profit' ;
sum1.operand = DataSourceSummaryOperand.Sum;
sum1.formatOverride = new Intl .NumberFormat('en-EN' , { style : 'currency' , currency : 'USD' , minimumFractionDigits : 0 , maximumFractionDigits : 0 });
this .grid.summaryDescriptions.add(sum1);
const avg2 = new IgcColumnSummaryDescription();
avg2.field = 'Profit' ;
avg2.operand = DataSourceSummaryOperand.Average;
avg2.formatOverride = new Intl .NumberFormat('en-EN' , { style : 'currency' , currency : 'USD' , minimumFractionDigits : 0 , maximumFractionDigits : 0 });
this .grid.summaryDescriptions.add(avg2);
const countries = new IgcColumnSummaryDescription();
countries.field = 'Countries' ;
countries.operand = DataSourceSummaryOperand.Custom;
countries.provideCalculator = this .onProvideCalculator;
this .grid.summaryDescriptions.add(countries);
}
onProvideCalculator (s: IgcColumnSummaryDescription, e: IgcProvideCalculatorEventArgs ) {
e.calculator = new CustomDomestic();
}
}
class CustomDomestic extends SummaryCalculator {
get displayName (): string {
return 'USA' ;
}
public usCountries: number ;
public beginCalculation(a: IDataSource, b : string ): void {
super .beginCalculation(a, b);
this .usCountries = 0 ;
}
public endCalculation(): ISummaryResult {
return new DefaultSummaryResult(this .propertyName, DataSourceSummaryOperand.Custom, this .usCountries)
}
public aggregate(a: any ): void {
if (a.Countries === 'USA' ) {
this .usCountries++;
}
}
}
new DataGridColumnSummaries();
ts コピー <!DOCTYPE html >
<html >
<head >
<title > DataGridColumnSummaries</title >
<meta charset ="UTF-8" />
<link rel ="shortcut icon" href ="https://static.infragistics.com/xplatform/images/browsers/wc.png" >
<link rel ="stylesheet" href ="https://fonts.googleapis.com/icon?family=Material+Icons" />
<link rel ="stylesheet" href ="https://fonts.googleapis.com/css?family=Kanit&display=swap" />
<link rel ="stylesheet" href ="https://fonts.googleapis.com/css?family=Titillium Web" />
<link rel ="stylesheet" href ="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" type ="text/css" />
</head >
<body >
<div id ="root" >
<div class ="container sample" >
<div class ="options horizontal" >
<span class ="options-label" > Summary Scope:</span >
<select class ="options-label" default-value ="Root" id ="onSummaryScopeChanging" >
<option > Root</option >
<option > Groups</option >
<option > Both</option >
<option > None</option >
</select >
<span class ="options-label" > Group Summary Display Mode:</span >
<select class ="options-label" default-value ="RowBottom" id ="onGroupSummaryDisplayModeChanging" >
<option > List</option >
<option > Cells</option >
<option > RowTop</option >
<option > RowBottom</option >
<option > None</option >
</select >
</div >
<igc-data-grid
id ="grid"
height ="calc(100% - 3rem)"
width ="100%"
summary-scope ="Root"
group-summary-display-mode ="RowTop"
auto-generate-columns ="false"
is-group-collapsable ="true"
group-header-display-mode ="combined"
is-column-options-enabled ="true"
default-column-min-width ="100"
>
<igc-numeric-column field ="ProductID" header-text ="ID" horizontal-alignment ="center" > </igc-numeric-column >
<igc-text-column field ="ProductName" header-text ="Product" width ="*>160" > </igc-text-column >
<igc-numeric-column positive-prefix ="$" field ="BundlePrice" show-grouping-separator ="true" header-text ="Price" > </igc-numeric-column >
<igc-numeric-column field ="OrderItems" header-text ="Order Items" width ="*>135" > </igc-numeric-column >
<igc-numeric-column field ="OrderValue" show-grouping-separator ="true" header-text ="Order Totals" positive-prefix ="$" width ="*>195" > </igc-numeric-column >
<igc-date-time-column field ="OrderDate" header-text ="Order Date" horizontal-alignment ="right" width ="*>180" > </igc-date-time-column >
<igc-numeric-column field ="Profit" show-grouping-separator ="true" header-text ="Profit" positive-prefix ="$" width ="*>165" > </igc-numeric-column >
<igc-text-column field ="Countries" header-text ="Country" width ="*>115" > </igc-text-column >
</igc-data-grid >
</div >
</div >
<% if (false) { %><script src ="src/index.ts" > </script > <% } %>
</body >
</html >
html コピー
このサンプルが気に入りましたか? 完全な Ignite UI for Web Componentsツールキットにアクセスして、すばやく独自のアプリの作成を開始します。無料でダウンロードできます。
SummaryScope プロパティ
グリッドでは、summaryScope
プロパティを使用して、構成できる4つの集計設定をサポートします。集計設定は以下のとおりです。
Root
: 集計が適用される列にグリッド全体の行の総計を表示します。
Groups
: これはグループ化された行に対して有効です。特定のグループ内の行の総計を表示します。
Both
: Groups
と Root
オプションを同時に使用します。
None
: グリッドの集計を無効にします。
GroupSummaryDisplayMode プロパティ
グリッドは、集計が表示される場所の構成をサポートします。これを構成するには、groupSummaryDisplayMode
プロパティを使用します。このプロパティのオプションは以下のとおりです。
List : グループ集計をスパン グループ ヘッダーのフラット リストにレンダリングします。
Cells : グループ ヘッダーをセルとしてレンダリングし、集計値を対応する列に揃えてセル内にレンダリングします。グリッドは、このオプションを使用して列ごとに 1 つの集計のみを表示します。
RowTop : グループ集計をグループの上部に集計行としてレンダリングします。
RowBottom : グループ集計をグループの下部に集計行としてレンダリングします。
None : グループ集計のレンダリングを無効にします。
コード スニペット
<igc-data-grid
summary-scope ="Root"
group-summary-display-mode ="RowTop"
auto-generate-columns ="false"
is-group-collapsable ="true"
group-header-display-mode ="combined"
default-column-min-width ="100" >
<igc-text-column field ="ProductName" header-text ="Product" > </igc-text-column >
<igc-numeric-column positive-prefix ="$" field ="BundlePrice" show-grouping-separator ="true" header-text ="Price" > </igc-numeric-column >
<igc-numeric-column field ="OrderItems" header-text ="Order Items" > </igc-numeric-column >
<igc-numeric-column field ="OrderValue" show-grouping-separator ="true" header-text ="Order Totals" positive-prefix ="$" > </igc-numeric-column >
<igc-text-column field ="Countries" header-text ="Ship Country" > </igc-text-column >
</igc-data-grid >
html
import { IgcColumnGroupDescription } from 'igniteui-webcomponents-grids' ;
import { IgcColumnSummaryDescription } from 'igniteui-webcomponents-grids'
import { SummaryOperand, SummaryCalculator, DefaultSummaryResult, IDataSource, ISummaryResult } from 'igniteui-webcomponents-core' ;
connectedCallback ( ) {
const productCount = new IgcColumnSummaryDescription();
productCount.field = "ProductName" ;
productCount.operand = SummaryOperand.Count;
this .grid.summaryDescriptions.add(productCount);
const priceMin = new IgcColumnSummaryDescription();
priceMin.field = "BundlePrice" ;
priceMin.operand = SummaryOperand.Min;
priceMin.formatOverride = new Intl .NumberFormat('en-EN' , { style : 'currency' , currency : 'USD' , minimumFractionDigits : 0 , maximumFractionDigits : 0 });
this .grid.summaryDescriptions.add(priceMin);
const priceMax = new IgcColumnSummaryDescription();
priceMax.field = "BundlePrice" ;
priceMax.operand = SummaryOperand.Max;
priceMax.formatOverride = new Intl .NumberFormat('en-EN' , { style : 'currency' , currency : 'USD' , minimumFractionDigits : 0 , maximumFractionDigits : 0 });
this .grid.summaryDescriptions.add(priceMax);
const orderSum = new IgcColumnSummaryDescription();
orderSum.field = "OrderItems" ;
orderSum.operand = SummaryOperand.Sum;
this .grid.summaryDescriptions.add(orderSum);
const orderValueAvg = new IgcColumnSummaryDescription();
orderValueAvg.field = "OrderValue" ;
orderValueAvg.operand = SummaryOperand.Average;
orderValueAvg.formatOverride = new Intl .NumberFormat('en-EN' , { style : 'currency' , currency : 'USD' , minimumFractionDigits : 0 , maximumFractionDigits : 0 });
this .grid.summaryDescriptions.add(orderValueAvg);
}
ts
カスタム集計
デフォルトの集計セットを拡張したい場合があります。たとえば、列の特定の値が表示される回数を表示する場合、カスタム集計が必要です。
以下のスニペットは、列に表示される 「USA」 値の数の Count を表示する方法を示します。
import { IgcProvideCalculatorEventArgs } from 'igniteui-webcomponents-core' ;
onLoad ( ) {
const countries = new IgcColumnSummaryDescription();
countries.field = "Countries" ;
countries.operand = SummaryOperand.Custom;
countries.provideCalculator = this .onProvideCalculator;
this .grid.summaryDescriptions.add(countries);
}
onProvideCalculator (s: IgcColumnSummaryDescription, e: IgcProvideCalculatorEventArgs ) {
e.calculator = new CustomDomestic();
}
class CustomDomestic extends SummaryCalculator
{
get displayName (): string {
return "USA" ;
}
public usCountries: number ;
public beginCalculation(a: IDataSource, b : string ): void {
super .beginCalculation(a,b);
this .usCountries = 0 ;
}
public endCalculation(): ISummaryResult {
return new DefaultSummaryResult(this .propertyName, SummaryOperand.Custom, this .usCountries)
}
public aggregate(a: any ): void {
if (a.Countries === "USA" )
{
this .usCountries++;
}
}
}
ts
API リファレンス