Web Components 그리드 다중 열 헤더 개요
Web Components Grid의 Ignite UI for Web Components 다중 열 헤더 기능은 열을 공통 다중 헤더 아래에 배치하여 그룹화할 수 있게 해줍니다. 각IgcGridComponent 다중 열 헤더 그룹은 다른 그룹이나 열의 조합을 표현할 수 있습니다. 이 기능은 특히 횡스크롤이 번거로울 수 있는 대규모 데이터셋을 다룰 때 유용합니다.
Web Components Grid Multi-Column Headers Example
다중 열 헤더의 선언은 여러 열을 컴포넌트에columnGroup 감싸고header 제목 정보를 전달함으로써 이루어집니다.
<igc-grid allow-filtering="true">
<igc-column-group header="Contact Information">
<igc-column sortable="true" resizable="true" field="Phone"></igc-column>
<igc-column sortable="true" resizable="true" field="Fax"></igc-column>
<igc-column sortable="true" resizable="true" field="PostalCode"></igc-column>
</igc-column-group>
</igc-grid>
중첩 헤더 수준을 달성n-th 하려면 위의 선언을 따라야 합니다. 그래서 중첩이columnGroup 원하는 결과를 낳는다.
<igc-grid height="600px" allow-filtering="true">
<igc-column-group header="General Information">
<igc-column movable="true" sortable="true" resizable="true" field="CompanyName"></igc-column>
<igc-column-group movable="true" header="Person Details">
<igc-column movable="true" pinned="false" sortable="true" resizable="true" field="ContactName"></igc-column>
<igc-column movable="true" sortable="true" resizable="true" field="ContactTitle"></igc-column>
</igc-column-group>
</igc-column-group>
</igc-grid>
모든columnGroup 지지대가 움직이 고, 고정 되고, 숨고 있습니다.
[!Note] When there is a set of columns and column groups, pinning works only for top level column parents. More specifically pinning per nested column groups or columns is not allowed.
Moving between columns and column groups is allowed only when they are at the same level in the hierarchy and both are in the samegroup.
Whencolumns/column-groupsare not wrapped by currentgroupwhich means they are top levelcolumns, moving is allowed between whole visible columns.
<igc-grid height="600px" allow-filtering="true">
<igc-column-group movable="true" pinned="true" header="General Information">
<igc-column movable="true" sortable="true" resizable="true" field="CompanyName"></igc-column>
</igc-column-group>
<igc-column sortable="true" resizable="true" field="Phone"></igc-column>
<igc-column sortable="true" resizable="true" field="Fax"></igc-column>
<igc-column sortable="true" resizable="true" field="PostalCode"></igc-column>
</igc-grid>
Multi-Column Header Template
격자의 각 열 그룹은 별도로 템플릿화할 수 있습니다. 다음 코드 스니펫은 열 그룹의 를headerTemplate 사용하는 방법을 보여줍니다:
<igc-column-group id="addressInfo" header="Address Information">
</igc-column-group>
constructor() {
var addresss = this.addresss = document.getElementById('addressInfo') as IgcColumnGroupComponent;
addresss.headerTemplate = this.columnGroupHeaderTemplate;
}
public columnGroupHeaderTemplate = (ctx: IgcColumnTemplateContext) => {
return html`
${ctx.column.header.toUpperCase()}
`;
}
여러 열 그룹에 단일 템플릿을 재사용하고 싶다면, 열 그룹의 속성을 다음과 같이 설정할headerTemplate 수 있습니다:
<igc-column-group id="generalInfo" header="General Information">
</igc-column-group>
<igc-column-group id="addressInfo" header="Address Information">
</igc-column-group>
constructor() {
var general = this.general = document.getElementById('generalInfo') as IgcColumnGroupComponent;
var addresss = this.address = document.getElementById('addressInfo') as IgcColumnGroupComponent;
general.headerTemplate = this.columnGroupHeaderTemplate;
addresss.headerTemplate = this.columnGroupHeaderTemplate;
}
public columnGroupHeaderTemplate = (ctx: IgcColumnTemplateContext) => {
return html`
${ctx.column.header.toUpperCase()}
`;
}
[!Note] If a header is re-templated and the corresponding column group is movable, you have to set the draggable attribute to false on the templated elements, so that you can handle any of the events that are applied!
public columnHeaderTemplate = (ctx: IgcColumnTemplateContext) => {
return html`
<igc-icon draggable="false" @click="${() => this.onClick()}"></igc-icon>
`;
}
다음 샘플은 헤더 템플릿을 사용하여 축소 가능한 열 그룹을 구현하는 방법을 보여줍니다.
Styling
사전 정의된 테마 외에도 사용 가능한 CSS 속성 중 일부를 설정하여 그리드를 추가로 사용자 정의할 수 있습니다. 일부 색상을 변경하려면 먼저 그리드에 대한 클래스를 설정해야 합니다.
<igc-grid class="grid"></igc-grid>
그런 다음 관련 CSS 속성을 이 클래스로 설정합니다.
.grid {
--ig-grid-header-background: #e0f3ff;
--ig-grid-header-text-color: #e41c77;
--ig-grid-header-border-width: 1px;
--ig-grid-header-border-style: solid;
--ig-grid-header-border-color: rgba(0, 0, 0, 0.08);
}
Demo
API References
Additional Resources
우리 커뮤니티는 활동적이며 항상 새로운 아이디어를 환영합니다.