Close
Angular React Web Components Blazor Blazor
Premium

Blazor Grid 複数列ヘッダーの概要

Blazor Grid の Ignite UI for Blazor 複数列ヘッダー機能は、共通の複数ヘッダーの下に配置することで列をグループ化できます。IgbGrid の各複数ヘッダー グループは、その他のグループや列を組み合わせて表示できます。この機能は、水平方向のスクロールが面倒な大規模なデータセットを扱う場合に特に役立ちます。

Blazor Grid 複数列ヘッダーの例

複数列ヘッダーの宣言は、一連の列を IgbColumnGroup コンポーネントにラップし、Header タイトル情報を渡すことによって実現されます。

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

ネストしたヘッダーの 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>

すべての IgbColumnGroup は、移動ピン固定、および非表示をサポートしています。

列セットと列グループがある場合、ピン固定は列の一番上の親レベルでのみ可能です。具体的には、ネストされた column groups または columns ごとのピン固定は許可されていません。
columns と column groups 間の移動は、それらが階層内の同じレベルにあり、両方が同じ group にある場合にのみ許可されます。
columns/column-groups が現在の group によってラップされていない場合 (一番上のレベル 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>

複数列ヘッダー テンプレート

グリッドの各列グループは個別のテンプレートを持つことができます。列グループは、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>;
    };
}

複数の列グループに対して 1 つのテンプレートを再利用する場合は、列グループの 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>;
    };
}

ヘッダーが再テンプレート化され、対応する列グループが移動可能な場合は、テンプレート要素で draggable 属性を false に設定する必要があり、これにより適用されるイベントをすべて処理できます。

@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"/>;
    };
}

次のサンプルは、ヘッダー テンプレートを使用して折りたたみ可能な列グループを実装する方法を示しています。

スタイル設定

定義済みのテーマに加えて、利用可能な CSS プロパティのいくつかを設定することで、グリッドをさらにカスタマイズできます。 一部の色を変更したい場合は、最初にグリッドのクラスを設定する必要があります。

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

次に、そのクラスに関連する CSS プロパティを設定します。

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

デモ

API リファレンス

IgbGrid
IgbColumn
IgbColumnGroup

その他のリソース

コミュニティに参加して新しいアイデアをご提案ください。