React Tree Grid 다중 컬럼 헤더 개요

    React 트리 그리드의 Ignite UI for React Multi-Column Headers 기능을 사용하면 공통 다중 헤더 아래에 열을 배치하여 그룹화할 수 있습니다. 의 IgrTreeGrid 각 다중 열 헤더 그룹은 다른 그룹 또는 열 간의 조합을 나타낼 수 있습니다. 이 기능은 가로로 스크롤하는 것이 번거로울 수 있는 대규모 데이터 세트를 처리할 때 특히 유용합니다.

    React Tree Grid Multi-Column Headers Example

    다중 열 헤더의 선언은 제목 정보가 전달된 header 구성 요소로 columnGroup 열 집합을 래핑하여 수행됩니다.

    <IgrTreeGrid primaryKey="ID" foreignKey="ParentID">
        <IgrColumnGroup header="Contact Information">
            <IgrColumn sortable={true} resizable={true} field="Phone" dataType="string"></IgrColumn>
            <IgrColumn sortable={true} resizable={true} field="Fax" dataType="string"></IgrColumn>
            <IgrColumn sortable={true} resizable={true} field="PostalCode" dataType="string"></IgrColumn>
        </IgrColumnGroup>
    </IgrTreeGrid>
    

    중첩된 헤더 수준을 달성 n-th 하려면 위의 선언을 따라야 합니다. 따라서 중첩 columnGroup을 통해 원하는 결과를 얻을 수 있습니다.

    <IgrTreeGrid primaryKey="ID" foreignKey="ParentID" moving={true}>
        <IgrColumnGroup pinned={false} header="General Information">
            <IgrColumn field="HireDate" sortable={true} resizable={true} dataType="date"></IgrColumn>
            <IgrColumnGroup header="Person Details">
                <IgrColumn field="ID" resizable={true} filterable={true} dataType="number"></IgrColumn>
                <IgrColumn field="Title" sortable={true} resizable={true} dataType="string"></IgrColumn>
                <IgrColumn field="Age" sortable={true} resizable={true} dataType="number"></IgrColumn>
            </IgrColumnGroup>
        </IgrColumnGroup>
    </IgrTreeGrid>
    

    모든 것은 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 same group.
    When columns/column-groups are not wrapped by current group which means they are top level columns, moving is allowed between whole visible columns.

    <IgrTreeGrid primaryKey="ID" foreignKey="ParentID" moving={true}>
        <IgrColumnGroup header="Contact Information">
            <IgrColumn field="Phone" movable={true} sortable={true} resizable={true} dataType="string"></IgrColumn>
        </IgrColumnGroup>
        <IgrColumn field="Name" sortable={true} resizable={true} dataType="string"></IgrColumn>
        <IgrColumn field="Title" sortable={true} resizable={true} dataType="string"></IgrColumn>
        <IgrColumn field="Age" sortable={true} resizable={true} dataType="number"></IgrColumn>
    </IgrTreeGrid>
    

    Multi-Column Header Template

    <IgrColumnGroup header="Contact Information" headerTemplate={groupHeaderTemplate}></IgrColumnGroup>
    
    const groupHeaderTemplate = (e: IgrColumnTemplateContext) => {
      const column = e.column as IgrColumnGroup;
      return (
        <div>
          <span style={{ float: "left" }}>{column.header.toUpperCase()}</span>
        </div>
      );
    }
    

    [!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!

    const columnHeaderTemplate = (e: IgrColumnTemplateContext ) => {
      const column = e.column as IgrColumnGroup;
      return (
        <span onClick={onClick}>
          <IgrIcon data-draggable="false"></IgrIcon>
        </span>
      );
    }
    

    다음 샘플은 헤더 템플릿을 사용하여 축소 가능한 열 그룹을 구현하는 방법을 보여줍니다.

    Styling

    사전 정의된 테마 외에도 사용 가능한 CSS 속성 중 일부를 설정하여 그리드를 추가로 사용자 정의할 수 있습니다. 일부 색상을 변경하려면 먼저 그리드에 대한 클래스를 설정해야 합니다.

    <IgrTreeGrid className="grid"></IgrTreeGrid>
    

    그런 다음 관련 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

    우리 커뮤니티는 활동적이며 항상 새로운 아이디어를 환영합니다.