Blazor Grid 그룹 작성자
The Ignite UI for Blazor Group By behavior in Blazor IgbGrid creates grouped data rows based on the column values. The Group By in the IgbGrid allows for visualizing the groups in a hierarchical structure. The grouped data rows can be expanded or collapsed and the order of grouping may be changed through the UI or API. When Row Selection is enabled, a Group By row selector is rendered in the left-most area of the group row. In case the RowSelection property is set to single, checkboxes are disabled and only serve as an indication for the group where selection is placed. If the RowSelection property is set to multiple, clicking over the Group By row selector selects all records belonging to this group.
Blazor Grid Group By Example
이 예에서는 대량의 데이터를 그룹화하는 기능을 보여줍니다. 열 헤더를 상단(그룹화 영역)으로 드래그하면 사용자는 선택한 열에 대한 데이터를 계층 구조로 볼 수 있습니다. 더 많은 열 헤더를 맨 위로 드래그하여 여러 필드에서 그룹화할 수 있습니다. 이러한 그룹화 옵션은 사용자가 훨씬 빠르고 시각적으로 허용되는 방식으로 데이터를 표시하려는 수많은 행과 열이 있는 테이블이 있는 경우 유용합니다.
초기 그룹화 상태
It is possible to define initial grouping of the grid by assigning an array of expressions to the GroupingExpressions property of the grid.
<IgbGrid AutoGenerate="true" Data="InvoicesData" @ref="grid" Id="grid" GroupingExpressions="GroupingExpression1"></IgbGrid>
@code {
public IgbGroupingExpression[] GroupingExpression1 = new IgbGroupingExpression[2]
{
new IgbGroupingExpression(){ FieldName = "ShipCountry", Dir= SortingDirection.Asc },
new IgbGroupingExpression() { FieldName = "ShipCity", Dir= SortingDirection.Asc }
};
}
Grouping expressions implement the ISortingExpression interface.
그룹화 API
그룹화 API
Grouping is available through the UI and through a robust API exposed by the grid component. Developers can allow end-users to group the grid data by certain columns, by setting each column's Groupable property to true.
<IgbGrid AutoGenerate="false" Data="InvoicesData" @ref="grid" Id="grid" GroupingExpressions="GroupingExpression1" GroupRowTemplateScript="WebGridGroupByRowTemplate">
<IgbColumn Field="OrderID" Hidden="true"></IgbColumn>
<IgbColumn Field="ShipCountry" Header="Ship Country" Width="200px" Groupable="true"></IgbColumn>
<IgbColumn Field="OrderDate" Header="Order Date" DataType="GridColumnDataType.Date" Width="200px" Groupable="true"></IgbColumn>
<IgbColumn Field="PostalCode" Header="Postal Code" Width="200px" Groupable="true"></IgbColumn>
<IgbColumn Field="Discontinued" Width="200px" DataType="GridColumnDataType.Boolean" Groupable="true" BodyTemplateScript="WebGridBooleanCellTemplate" Name="column1" @ref="column1"></IgbColumn>
<IgbColumn Field="ShipName" Header="Ship Name" Width="200px" Groupable="true"></IgbColumn>
<IgbColumn Field="ShipCity" Header="Ship City" Width="200px" Groupable="true"></IgbColumn>
<IgbColumn Field="ShipperName" Header="Shipper Name"Width="200px"Groupable="true"></IgbColumn>
<IgbColumn Field="Salesperson" Header="Sales Person" Width="200px" Groupable="true"></IgbColumn>
<IgbColumn Field="UnitPrice" Header="Unit Price" Width="200px" Groupable="true"></IgbColumn>
<IgbColumn Field="Quantity" Width="200px" Groupable="true"></IgbColumn>
</IgbGrid>
During runtime the expressions are gettable and settable from the groupingExpressions property. If you need to add or change an existing expression you may also use the GroupBy method with either a single or an array of expressions.
@code {
public IgbGrid grid;
public IgbGroupingExpression[] GroupingExpression1 = new IgbGroupingExpression[2]
{
new IgbGroupingExpression(){ FieldName = "ShipCountry", Dir= SortingDirection.Asc },
new IgbGroupingExpression() { FieldName = "ShipCity", Dir= SortingDirection.Asc }
};
private void GroupGrid()
{
this.grid.GroupBy(GroupingExpression1);
}
}
확장/축소 API
In addition to grouping expressions you can also control the expansion states for group rows. They are stored in a separate property of the IgbGrid component GroupingExpansionState which is a collection of IgbGroupByExpandState. Each expansion state is uniquely defined by the field name it is created for and the value it represents for each level of grouping, i.e. the identifier is a hierarchy array of IgbGroupByKey.
As with GroupingExpressions, setting a list of IgbGroupByExpandState directly to the GroupingExpansionState will change the expansion accordingly. Additionally IgbGrid exposes a method ToggleGroup that toggles a group by the group record instance or via the Expanded property of the row.
<IgbGrid AutoGenerate="true" Data="InvoicesData" GroupingExpressions="GroupingExpression1" GroupingExpansionState=ExpansionState @ref="grid" Id="grid">
</IgbGrid>
@code {
public IgbGroupingExpression[] GroupingExpression1 = new IgbGroupingExpression[2]
{
new IgbGroupingExpression(){ FieldName = "ShipCountry", Dir= SortingDirection.Asc },
new IgbGroupingExpression() { FieldName = "ShipCity", Dir= SortingDirection.Asc }
};
public IgbGroupByExpandState[] state = new IgbGroupByExpandState[1]
{
new IgbGroupByExpandState(){ Hierarchy = new IgbGroupByKey[1]{ new IgbGroupByKey() { FieldName="ShipCountry", Value = "USA" } }, Expanded = false }
};
}
Groups can be created expanded (default) or collapsed and the expansion states would generally only contain the state opposite to the default behavior. You can control whether groups should be created expanded or not through the GroupsExpanded property.
그룹 API의 모든 행 선택/선택 취소
Selecting/Deselecting all rows in a group is available through the SelectRowsInGroup and DeselectRowsInGroup API methods.
The code snippet below can be used to select all rows within a group using the group record instance SelectRowsInGroup method. Additionally, the second parameter of this method is a boolean property through which you may choose whether the previous row selection will be cleared or not. The previous selection is preserved by default.
var row = await this.grid.GetRowByIndexAsync(0);
this.grid.SelectRowsInGroup(row.GroupRow, true);
If you need to deselect all rows within a group programmatically, you can use the DeselectRowsInGroup method.
var row = await this.grid.GetRowByIndexAsync(0);
this.grid.DeselectRowsInGroup(row.GroupRow);
템플릿
그룹 행 템플릿
The group row except for the expand/collapse UI is fully templatable. By default it renders a grouping icon and displays the field name and value it represents. The context to render the template against is of type IgbGroupByRecord.
예를 들어, 다음 템플릿은 그룹 행 요약을 더욱 자세하게 만듭니다.
<IgbGrid AutoGenerate="true" Data="InvoicesData" @ref="grid" Id="grid" GroupRowTemplateScript="WebGridGroupByRowTemplate"></IgbGrid>
//In JavaScript:
igRegisterScript("WebGridGroupByRowTemplate", (ctx) => {
var html = window.igTemplating.html;
var groupRow = ctx.implicit;
return html`<span>Total items with value: ${groupRow.value} are ${groupRow.records.length}</span>`;
}, false);
그룹 행 선택기 템플릿
As mentioned above the group row except for the expand/collapse UI is fully templatable. To create a custom Group By row selector template use GroupByRowSelectorTemplate. From the template, you can access the implicitly provided context variable, with properties that give you information about the Group By row's state.
The SelectedCount property shows how many of the group records are currently selected while TotalCount shows how many records belong to the group.
<IgbGrid GroupByRowSelectorTemplateScript="GroupByRowSelectorTemplate"></IgbGrid>
//In Javascript
igRegisterScript("GroupByRowSelectorTemplate", (ctx) => {
var html = window.igTemplating.html;
return html` ${ctx.implicit.selectedCount} / ${ctx.implicit.totalCount} `;
}, false);
The GroupRow property returns a reference to the group row.
<IgbGrid GroupByRowSelectorTemplateScript="GroupByRowSelectorTemplate"></IgbGrid>
//In Javascript
igRegisterScript("GroupByRowSelectorTemplate", (ctx) => {
var html = window.igTemplating.html;
var groupRow = ctx.implicit.groupRow;
return html`<div onclick="handleGroupByRowSelectorClick()">Handle groupRow</div> `;
}, false);
The SelectedCount and TotalCount properties can be used to determine if the Group By row selector should be checked or indeterminate (partially selected).
Blazor Grid Group By With Paging
그룹 행은 데이터 행과 함께 페이징 프로세스에 참여합니다. 각 페이지의 페이지 크기에 포함됩니다. 축소된 행은 페이징 프로세스에 포함되지 않습니다. 확장 또는 축소 작업을 수행하면 Paging이 페이지 수를 다시 계산하고 필요한 경우 페이지 인덱스를 조정합니다. 여러 페이지에 걸쳐 있는 그룹은 페이지 간에 분할됩니다. 그룹 행은 시작하는 페이지에만 표시되며 후속 페이지에서는 반복되지 않습니다. 그룹 행의 요약 정보는 전체 그룹을 기준으로 계산되며 Paging의 영향을 받지 않습니다.
Blazor Group By With Paging Example
요약으로 그룹화
Group By와 요약 간의 통합은 요약 항목에 설명되어 있습니다.
키보드 탐색
그룹화 UI는 다음과 같은 키보드 상호 작용을 지원합니다.
그룹 행의 경우(포커스는 행 또는 확장/축소 셀에 있어야 함)
- ALT + RIGHT- 그룹 확장
- ALT + LEFT- 그룹 축소
- SPACE-rowSelection 속성이 다중으로 설정된 경우 그룹의 모든 행을 선택합니다.
For group
IgbChipcomponents in the group by area (focus should be on the chip)- SHIFT + LEFT- 가능한 경우 그룹화 순서를 변경하여 초점을 맞춘 칩을 왼쪽으로 이동합니다.
- SHIFT + 오른쪽- 가능한 경우 그룹화 순서를 변경하여 초점을 맞춘 칩을 오른쪽으로 이동합니다.
- SPACE- 정렬 방향을 변경합니다.
- DELETE- 필드 그룹을 해제합니다.
- 칩의 개별 요소도 초점을 맞출 수 있으며 키를 사용하여 상호 작용할 수 있습니다 ENTER.
스타일링
사전 정의된 테마 외에도 사용 가능한 CSS 속성 중 일부를 설정하여 그리드를 추가로 사용자 정의할 수 있습니다. 일부 색상을 변경하려면 먼저 그리드에 대한 클래스를 설정해야 합니다.
<IgbGrid Class="grid"></IgbGrid>
그런 다음 해당 클래스에 대한 관련 CSS 속성을 설정합니다.
.grid {
--ig-grid-group-row-background: #969799;
--ig-grid-group-row-selected-background: #969799;
--ig-grid-group-label-column-name-text: #f8f8f8;
--ig-grid-group-label-text: #f8f8f8;
--ig-grid-group-count-text-color: #222;
--ig-grid-expand-icon-color: #f8f8f8;
--ig-grid-expand-icon-hover-color: #f8f8f8;
}
데모
알려진 제한 사항
| 한정 | 설명 |
|---|---|
| 그룹화된 열의 최대 개수는 10개입니다. | 10개 이상의 열이 그룹화되면 오류가 발생합니다. |
API 참조
IgbGridIgbGroupByRecordISortingExpressionColumnIGroupByExpandStateIgbChip
추가 리소스
우리 커뮤니티는 활동적이며 항상 새로운 아이디어를 환영합니다.