Web Components 계층적 그리드 다중 열 헤더 개요
The Ignite UI for Web Components Multi-Column Headers feature in Web Components Hierarchical Grid allows you to group columns by placing them under a common multi-header. Each multi-column headers group in the IgcHierarchicalGridComponent could be a representation of combinations between other groups or columns. This feature is particularly useful when dealing with large datasets where scrolling horizontally might be cumbersome.
Web Components Hierarchical Grid Multi-Column Headers Example
The declaration of multi-column headers is achieved by wrapping a set of columns into an columnGroup component with header title information passed.
<igc-hierarchical-grid auto-generate="false" name="hierarchicalGrid" id="hierarchicalGrid" primary-key="ID" moving="true" allow-filtering="true">
<igc-column field="CustomerID" sortable="true" resizable="true"> </igc-column>
<igc-column-group header="Address Information">
<igc-column-group header="Location">
<igc-column field="Address" sortable="true" resizable="true"></igc-column>
<igc-column field="City" sortable="true" resizable="true"></igc-column>
<igc-column field="PostalCode" sortable="true" resizable="true"></igc-column>
<igc-column field="Country" sortable="true" resizable="true"></igc-column>
</igc-column-group>
<igc-column-group header="Contact Information">
<igc-column field="Phone" sortable="true" resizable="true"></igc-column>
<igc-column field="Fax" sortable="true" resizable="true"></igc-column>
</igc-column-group>
</igc-column-group>
</igc-hierarchical-grid>
중첩 헤더 수준을 달성n-th 하려면 위의 선언을 따라야 합니다. 그래서 중첩이columnGroup 원하는 결과를 낳는다.
<igc-hierarchical-grid auto-generate="false" name="hierarchicalGrid" id="hierarchicalGrid" primary-key="ID" moving="true" allow-filtering="true">
<igc-column field="CustomerID" dataType="string" sortable="true" resizable="true"> </igc-column>
<igc-column-group header="General Information">
<igc-column field="CompanyName" dataType="string" sortable="true" resizable="true"></igc-column>
<igc-column-group header="Person Details">
<igc-column field="ContactName" dataType="string" sortable="true" resizable="true"></igc-column>
<igc-column field="ContactTitle" dataType="string" sortable="true" resizable="true"></igc-column>
</igc-column-group>
</igc-column-group>
</igc-hierarchical-grid>
Every columnGroup supports moving, pinning and hiding.
[!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-hierarchical-grid auto-generate="false" name="hierarchicalGrid" id="hierarchicalGrid" primary-key="ID" moving="true" allow-filtering="true">
<igc-column field="CustomerID" dataType="string" movable="true" pinned="true" sortable="true" resizable="true"> </igc-column>
<igc-column-group movable="true" pinned="true" header="General Information">
<igc-column field="CompanyName" dataType="string" sortable="true" resizable="true"></igc-column>
<igc-column-group header="Person Details">
<igc-column field="ContactName" dataType="string" sortable="true" resizable="true"></igc-column>
<igc-column field="ContactTitle" dataType="string" sortable="true" resizable="true"></igc-column>
</igc-column-group>
</igc-column-group>
</igc-hierarchical-grid>
Multi-Column Header Template
Each of the column groups of the grid can be templated separately. The following code snippet demonstrates how to use the headerTemplate of a column group:
<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-hierarchical-grid class="grid"></igc-hierarchical-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
우리 커뮤니티는 활동적이며 항상 새로운 아이디어를 환영합니다.