Ignite UI for Angular의 그리드는 다음을 제공합니다. IgxGridToolbarComponent 본질적으로 컨테이너입니다 사용자 인터페이스 작업. Angular 툴바는 Angular 구성 요소, 즉 Grid의 맨 위에 있으며 가로 크기와 일치합니다. 툴바 컨테이너는 다음 Grid 기능에 대한 미리 정의된 UI 컨트롤을 호스팅할 수 있습니다.
열 숨기기
열 고정
엑셀 내보내기
고급 필터링
또는 다른 사용자 정의 콘텐츠. 툴바와 사전 정의된 UI 구성 요소는 Angular 이벤트를 지원하고 개발자를 위한 API를 노출합니다.
最速で機能豊富な Angular Data Grid は、ページング、ソート、フィルタリング、グループ化、PDF および Excel へのエクスポートなどの機能を提供します。究極のアプリ構築エクスペリエンスとデータ操作に必要なすべてが揃っています。
<divclass="grid__wrapper"><igx-grid [igxPreventDocumentScroll]="true" #grid1id="grid1" [data]="data" [autoGenerate]="false"height="400px"><igx-grid-toolbar><igx-grid-toolbar-title>Grid Toolbar</igx-grid-toolbar-title><igx-grid-toolbar-actions><igx-grid-toolbar-advanced-filtering></igx-grid-toolbar-advanced-filtering><igx-grid-toolbar-hiding></igx-grid-toolbar-hiding><igx-grid-toolbar-pinning></igx-grid-toolbar-pinning><igx-grid-toolbar-exporter></igx-grid-toolbar-exporter></igx-grid-toolbar-actions></igx-grid-toolbar><igx-columnfield="Name"header="Athlete"width="200"><ng-templateigxCelllet-cell="cell"><divclass="cell__inner"><igx-avatar [src]="cell.row.data.Avatar"shape="circle"size="small"></igx-avatar><spanclass="athlete_name">{{ cell.value }}</span></div></ng-template></igx-column><igx-columnfield="CountryName"header="Country"width="200"><ng-templateigxCelllet-cell="cell"><divclass="cell__inner"><igx-avatar [src]="cell.row.data.CountryFlag"shape="circle"size="small"></igx-avatar><spanclass="country_name">{{ cell.value }}</span></div></ng-template></igx-column><igx-columnfield="BeatsPerMinute"header="Beats Per Minute"><ng-templateigxCelllet-val><divclass="cell__inner">{{ val }}</div></ng-template></igx-column><igx-columnfield="TopSpeed"header="Top Speed"><ng-templateigxCelllet-val><divclass="cell__inner">{{ val }}</div></ng-template></igx-column><igx-columnfield="AthleteNumber"header="ID"><ng-templateigxCelllet-val><divclass="cell__inner">{{ val }}</div></ng-template></igx-column><igx-columnfield="TrackProgress"header="Progress"><ng-templateigxCelllet-val><divclass="cell__inner">{{ val }}</div></ng-template></igx-column></igx-grid></div>html
툴바는 그리드 전체에 영향을 미치는 로직/상호 작용을 분리하는 데 매우 유용합니다. 위에 표시된 대로, 그리드에서 제어, 열 숨기기, 열 고정, 고급 필터링 및 데이터 내보내기를 위한 기본 구성 요소를 제공하도록 구성할 수 있습니다. 이러한 기능은 Ignite UI for Angular 제품군의 카드 구성 요소와 유사한 패턴을 따르면 서로 독립적으로 활성화할 수 있습니다. 아래에 툴바의 주요 기능과 각 기능에 대한 예제 코드가 나와 있습니다.
public data: any[];
public positionStrategyScaleCenter = new GlobalPositionStrategy({
openAnimation: scaleInCenter,
closeAnimation: scaleOutCenter
});
public overlaySettingsScaleCenter = {
positionStrategy: this.positionStrategyScaleCenter,
scrollStrategy: new AbsoluteScrollStrategy(),
modal: true,
closeOnEscape: true
};
public positionStrategyAuto = new AutoPositionStrategy();
public overlaySettingsAuto = {
positionStrategy: this.positionStrategyAuto,
scrollStrategy: new AbsoluteScrollStrategy(),
modal: false,
closeOnEscape: false
};
constructor() {
this.data = athletesData;
}
ts
기본 overlaySettings는 Absolute 스크롤 전략과 함께 ConnectedPositionStrategy를 사용하고, 모달은 false로 설정되며, 이스케이프 시 닫기 및 외부 클릭 상호 작용 시 닫기가 활성화됩니다.
열 고정
도구 모음 고정 구성 요소는 그리드의 열 고정과 상호 작용하기 위한 기본 UI를 제공합니다. 구성 요소는 구성 요소 제목, 구성 요소 입력을 위한 자리 표시자 및 드롭다운 자체의 높이와 같은 UI 사용자 정의를 위한 여러 입력 속성뿐만 아니라 도구 모음이 포함된 상위 그리드를 사용하여 즉시 작동하도록 설정됩니다.
도구 모음 고급 필터링 구성 요소는 고급 필터링 기능을 위한 기본 UI를 제공합니다. 구성 요소는 버튼의 기본 텍스트를 변경하는 방법을 노출합니다.
<igx-grid-toolbar><igx-grid-toolbar-actions><igx-grid-toolbar-advanced-filtering>Custom text for the toggle button</igx-grid-toolbar-advanced-filtering></igx-grid-toolbar-actions></igx-grid-toolbar>html
데이터 내보내기
나머지 툴바 작업과 마찬가지로 내보내기는 기본적으로 Toolbar Exporter 구성 요소를 통해 제공됩니다. 내보내기 구성 요소는 대상 데이터 형식(Excel CSV)에 대한 해당 서비스를 사용합니다. 즉, 해당 서비스가 종속성 주입 체인을 통해 제공되지 않으면 구성 요소는 아무것도 내보낼 수 없습니다. Angular에서 DI에 대한 새로 고침이 필요한 경우 공식 가이드를 확인하세요. 다음은 애플리케이션의 모든 내보내기 서비스를 활성화하는 방법을 보여주는 샘플 스니펫입니다.
v12.2.1 이상에서는 내보내기 서비스가 루트에서 제공됩니다. 즉, 더 이상 AppModule 공급자에서 이를 선언할 필요가 없습니다.
도구 모음 내보내기 구성 요소는 UI와 내보내기 환경을 모두 사용자 지정하기 위한 여러 입력 속성을 노출합니다. 표시 텍스트 변경부터 드롭다운 옵션 활성화/비활성화, 생성된 파일 이름 사용자 정의까지 다양합니다. 자세한 내용은 도구 모음 내보내기 구성요소에 대한 API 문서를 참조하세요.
다음은 Angular 템플릿을 통해 사용자 정의할 수 있는 일부 옵션을 보여주는 스니펫입니다.
<igx-grid-toolbar><igx-grid-toolbar-actions><igx-grid-toolbar-exporter
<!--Ifactive, enablesthecsvexportentryinthedropdownUI-->
[exportCSV]="csvExportEnabled"
<!-- If active, enables the excel export entry in the dropdown UI -->
[exportExcel]="excelExportEnabled"
<!-- The name of the generated export file without the file extension -->
filename="exported_data"
>
Custom text for the exporter button
<spanexcelText>Custom text for the excel export entry</span><spancsvText>Custom text for the CSV export entry</span></igx-grid-toolbar-exporter></igx-grid-toolbar-actions></igx-grid-toolbar>html
내보낸 파일 이름을 변경하는 것 외에도 사용자는 도구 모음Exporting 이벤트를 기다리고 이벤트 속성에서 옵션 항목을 사용자 정의하여 내보내기 옵션을 추가로 구성할 수 있습니다.
기본적으로 CSV로 내보낼 때 내보내기는 쉼표 구분 기호를 사용하여 내보내고 출력 파일에 '.csv' 확장자를 사용합니다. 내보내기 이벤트를 구독하거나 내보내기 옵션 필드의 값을 변경하여 이러한 내보내기 매개변수를 사용자 정의할 수 있습니다. 이벤트 인수의 취소 필드를 true로 설정하여 내보내기 프로세스를 취소할 수도 있습니다.
다음 코드 조각은 도구 모음 내보내기 이벤트를 구독하고 내보내기 옵션을 구성하는 방법을 보여줍니다.
<divclass="grid__wrapper"><igx-grid [igxPreventDocumentScroll]="true" #grid1id="grid1" [data]="data" [autoGenerate]="false"height="400px"
(toolbarExporting)="configureExport($event)"
><igx-grid-toolbar><igx-grid-toolbar-title>Grid toolbar</igx-grid-toolbar-title><igx-grid-toolbar-actions><igx-grid-toolbar-exporter></igx-grid-toolbar-exporter></igx-grid-toolbar-actions></igx-grid-toolbar><igx-columnfield="Name"header="Athlete"width="200"><ng-templateigxCelllet-cell="cell"><divclass="cell__inner"><igx-avatar [src]="cell.row.data.Avatar"shape="circle"size="small"></igx-avatar><spanclass="athlete_name">{{ cell.value }}</span></div></ng-template></igx-column><igx-columnfield="CountryName"header="Country"width="200"><ng-templateigxCelllet-cell="cell"><divclass="cell__inner"><igx-avatar [src]="cell.row.data.CountryFlag"shape="circle"size="small"></igx-avatar><spanclass="country_name">{{ cell.value }}</span></div></ng-template></igx-column><igx-columnfield="BeatsPerMinute"header="Beats Per Minute"><ng-templateigxCelllet-val><divclass="cell__inner">{{ val }}</div></ng-template></igx-column><igx-columnfield="TopSpeed"header="Top Speed"><ng-templateigxCelllet-val><divclass="cell__inner">{{ val }}</div></ng-template></igx-column><igx-columnfield="AthleteNumber"header="ID"><ng-templateigxCelllet-val><divclass="cell__inner">{{ val }}</div></ng-template></igx-column><igx-columnfield="TrackProgress"header="Progress"><ng-templateigxCelllet-val><divclass="cell__inner">{{ val }}</div></ng-template></igx-column></igx-grid></div>html
기본 도구 모음 내보내기 구성 요소를 사용하는 경우 내보내기 작업이 수행될 때마다 작업이 진행되는 동안 도구 모음에 진행률 표시기가 표시됩니다. 또한 사용자는 도구 모음 showProgress 속성을 설정하고 자신의 장기 실행 작업에 사용하거나 그리드에서 발생하는 작업을 나타내는 다른 방법으로 사용할 수 있습니다. 아래 샘플에는 상당한 양의 데이터가 있습니다. 데이터를 내보내는 동안 진행률 표시줄이 표시됩니다. 또한 그리드에서 장기 실행 작업을 시뮬레이션하는 또 다른 단추가 있습니다.
이는 이전 도구 모음 템플릿 지시문을 대체합니다. v11 이전 버전에서 마이그레이션하는 경우 마이그레이션에서 템플릿 콘텐츠 이동이 처리됩니다. 단, 템플릿 내 바인딩은 당사에서 처리하지 않으므로 마이그레이션 완료 후 수정된 템플릿 파일을 반드시 다시 확인하시기 바랍니다.
도구 모음 구성 요소의 작업 부분이 특정 사용 사례에 충분하지 않은 경우 도구 모음 자체에는 사용자가 추가 UI를 제공할 수 있는 일반 콘텐츠 프로젝션이 있습니다. 사용자가 API 호출 또는 바인딩을 위해 해당 그리드 인스턴스가 필요한 경우 템플릿 참조 변수를 만들 수 있습니다.
다음은 샘플 스니펫입니다.
<igx-grid #gridRef...>
...
<igx-grid-toolbar><igx-grid-toolbar-title>{{ titleBinding }}</igx-grid-toolbar-title><!--
Everything between the toolbar tags except the default toolbar components/directives
will be projected as custom content.
--><buttonigxButton="flat"igxRipple (click)="#gridRef.clearSort()"><igx-iconfontSet="material">clear</igx-icon>
Clear Sort
</button><igx-grid-toolbar-actions>
...
</igx-grid-toolbar-actions></igx-grid-toolbar></igx-grid>html
다음 샘플은 열 헤더를 클릭하여 정렬 설정을 지우기 위해 도구 모음에 추가 버튼을 추가하는 방법을 보여줍니다.
툴바 스타일링을 시작하려면 모든 테마 기능과 구성 요소 믹스인이 있는 인덱스 파일을 가져와야 합니다.
@use"igniteui-angular/theming" as *;
// IMPORTANT: Prior to Ignite UI for Angular version 13 use:// @import '~igniteui-angular/lib/core/styles/themes/index';scss
<divclass="grid__wrapper"><igx-grid [igxPreventDocumentScroll]="true" #grid1id="grid1" [data]="data" [autoGenerate]="false"height="400px"><igx-grid-toolbar><igx-grid-toolbar-title>Grid Toolbar</igx-grid-toolbar-title><igx-grid-toolbar-actions><igx-grid-toolbar-hiding></igx-grid-toolbar-hiding><igx-grid-toolbar-pinning></igx-grid-toolbar-pinning><igx-grid-toolbar-exporter></igx-grid-toolbar-exporter></igx-grid-toolbar-actions></igx-grid-toolbar><igx-columnfield="Name"header="Athlete"width="200"><ng-templateigxCelllet-cell="cell"><divclass="cell__inner"><igx-avatar [src]="cell.row.data.Avatar"shape="circle"size="small"></igx-avatar><spanclass="athlete_name">{{ cell.value }}</span></div></ng-template></igx-column><igx-columnfield="CountryName"header="Country"width="200"><ng-templateigxCelllet-cell="cell"><divclass="cell__inner"><igx-avatar [src]="cell.row.data.CountryFlag"shape="circle"size="small"></igx-avatar><spanclass="country_name">{{ cell.value }}</span></div></ng-template></igx-column><igx-columnfield="BeatsPerMinute"header="Beats Per Minute" ><ng-templateigxCelllet-val><divclass="cell__inner">{{ val }}</div></ng-template></igx-column><igx-columnfield="TopSpeed"header="Top Speed"><ng-templateigxCelllet-val><divclass="cell__inner">{{ val }}</div></ng-template></igx-column><igx-columnfield="AthleteNumber"header="ID"><ng-templateigxCelllet-val><divclass="cell__inner">{{ val }}</div></ng-template></igx-column><igx-columnfield="TrackProgress"header="Progress"><ng-templateigxCelllet-val><divclass="cell__inner">{{ val }}</div></ng-template></igx-column></igx-grid></div>html