Blazor Grid 다중 열 헤더 개요

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

    Blazor Grid Multi-Column Headers Example

    EXAMPLE
    DATA
    MODULES
    RAZOR
    CSS

    Like this sample? Get access to our complete Ignite UI for Blazor toolkit and start building your own apps in minutes. Download it for free.

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

    <IgbGrid Data=data AllowFiltering=true>
        <IgbColumnGroup Header="Contact Information">
            <IgbColumn Field="Phone" Sortable=true Resizable=true></IgbColumn>
            <IgbColumn Field="Fax" Sortable=true Resizable=true></IgbColumn>
            <IgbColumn Field="PostalCode" Sortable=true Resizable=true></IgbColumn>
        </IgbColumnGroup>
    </IgbGrid>
    razor

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

    <IgbGrid Data=data AllowFiltering=true>
        <IgbColumnGroup Header="General Information">
            <IgbColumn Field="CompanyName" Sortable=true Resizable=true Movable=true></IgbColumn>
            <IgbColumnGroup Header="Person Details" Movable=true>
                <IgbColumn Field="ContactName" Sortable=true Resizable=true Movable=true></IgbColumn>
                <IgbColumn Field="ContactTitle" Sortable=true Resizable=true Movable=true></IgbColumn>
            </IgbColumnGroup>
        </IgbColumnGroup>
    </IgbGrid>
    razor

    모든 IgbColumnGroup​ ​이동, 고정숨기기를 지원합니다.

    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.

    <IgbGrid Data=data AllowFiltering=true>
        <IgbColumnGroup Header="General Information" Pinned=true>
            <IgbColumn Field="CompanyName" Sortable=true Resizable=true Movable=true></IgbColumn>
        </IgbColumnGroup>
        <IgbColumn Field="Phone" Sortable=true Resizable=true></IgbColumn>
        <IgbColumn Field="Fax" Sortable=true Resizable=true></IgbColumn>
        <IgbColumn Field="PostalCode" Sortable=true Resizable=true></IgbColumn>
    </IgbGrid>
    razor

    Multi-Column Header Template

    그리드의 각 열 그룹은 별도로 템플릿화할 수 있습니다. 열 그룹은 HeaderTemplate 속성에 대해 RenderFragment 기대합니다. 표현식은 열 그룹 개체와 함께 컨텍스트로 제공됩니다.

    <IgbColumnGroup Header="Address Information" HeaderTemplate="Template">
    </IgbColumnGroup>
    
    @code {
        public RenderFragment<IgbColumnTemplateContext> Template = (ctx) => {
            string value = ctx.Column.Header.ToUpper();
            return @<span>@value</span>;
        };
    }
    razor

    여러 열 그룹에 대해 단일 템플릿을 다시 사용하려면 다음과 같이 열 그룹의 속성을 설정할 HeaderTemplate 수 있습니다.

    <IgbColumnGroup Header="General Information" HeaderTemplate="Template">
    </IgbColumnGroup>
    <IgbColumnGroup Header="Address Information" HeaderTemplate="Template">
    </IgbColumnGroup>
    
    @code {
        public RenderFragment<IgbColumnTemplateContext> Template = (ctx) => {
            string value = ctx.Column.Header.ToUpper();
            return @<span>@value</span>;
        };
    }
    razor

    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!

    @code {
        public Dictionary<string, object> DraggableAttributes { get; set; } =
            new Dictionary<string, object>()
            {
                { "draggable", "false" }
            };
    
        public RenderFragment<IgbColumnTemplateContext> Template = (ctx) => {
            return @<IgbIcon AdditionalAttributes="DraggableAttributes"  @onclick="onClick"/>;
        };
    }
    razor

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

    EXAMPLE
    DATA
    MODULES
    RAZOR
    JS
    CSS

    Styling

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

    <IgbGrid class="grid"></IgbGrid>
    razor

    그런 다음 관련 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);
    }
    css

    Demo

    EXAMPLE
    DATA
    MODULES
    RAZOR
    CSS

    API References

    Additional Resources

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