Blazor 다중 열 콤보 상자 개요
다중 열 콤보 상자는 데이터 개체의 속성에 대한 열을 자동으로 생성합니다. 이 구성 요소는 드롭다운에 포함된 데이터 그리드와 유사하게 대량의 데이터를 시각화하는 콤보 상자라는 점에서 독특합니다.
Blazor Multi-Column Combo Box Example
이 샘플은 팝업 창에서 여러 열로 데이터를 표시하는 방법을IgbMultiColumnComboBox 보여줍니다.
Component Modules
다중 열 콤보 상자에는 다음 모듈이 필요합니다.
// in Program.cs file
builder.Services.AddIgniteUIBlazor(
typeof(IgbMultiColumnComboBoxModule));
Usage
Binding a Data Source
다중 열 콤보 박스 컴포넌트에 객체를 표시하려면 속성을 바인딩DataSource 해야 합니다. 이것은 복잡한 객체들의 배열 형태로 결합될 수 있습니다. 다음 코드는 데이터 소스 속성을 바인딩하는 방법을 보여줍니다.
<IgbMultiColumnComboBox Height="50px" Width="400px" DataSource="CountryNames" />
@code {
protected List<CountryInfo> CountryNames;
protected override void OnInitialized()
{
this.CountryNames = CountryTreeData.Create();
}
}
Setting Display Value and Data Value
멀티 컬럼 콤보 박스의 바운DataSource 딩은 컨트롤의 표시 텍스트 역할뿐만 아니라 선택 시 기본 값으로도 다양한 속성을 설정할 수 있습니다. 이는 컨트롤의 속성TextField과 속성을 각각 표현하려는 데이터 항목의 속성 이름으로 설정ValueField 함으로써 이루어집니다.
컴포넌트의 값을 프로그래밍적으로 업데이트해야 한다면, 이벤트를ValueChanged 처리해야 합니다. andGetValue 메서드는GetValueAsync 이벤트 핸들러 내에 없ValueChanged을 때 값을 얻는 데 사용할 수 있습니다.
<IgbMultiColumnComboBox Height="50px" Width="400px"
DataSource="CountryNames"
TextField="Country"
ValueField="@(new string[]{ "ID" })" />
@code {
protected List<CountryInfo> CountryNames;
protected override void OnInitialized()
{
this.CountryNames = CountryTreeData.Create();
}
}
Setting Fields
기본적으로 다중 열 콤보 박스는 기본 데이터 항목의 모든 속성을 보여주지만, 이는 컴포넌트에 속성을 설정Fields 하여 제어할 수 있습니다. 이 속성은 기본 데이터 항목에 대한 속성 경로 중 하나를string[] 사용하여 어떤 속성이 표시될지 결정합니다.
다음 코드 조각은 이를 설정하는 방법을 보여 주며 결과 드롭다운에는 ID 및 국가 열만 표시됩니다.
<IgbMultiColumnComboBox Height="50px" Width="400px"
DataSource="CountryNames"
Fields="@(new string[] { "ID", "Country" })" />
@code {
protected List<CountryInfo> CountryNames;
protected override void OnInitialized()
{
this.CountryNames = CountryTreeData.Create();
}
}
Setting Placeholder Text
다중 열 콤보 박스 컴포넌트에 선택이 없을 때 표시되는 텍스트를 자리 표시자로 설정할 수 있습니다. 이는 표시하고자 하는 문자열에 속성을 설정Placeholder 함으로써 이루어집니다. 다음 코드는 이를 설정하는 방법을 보여줍니다:
<IgbMultiColumnComboBox Height="50px" Width="400px"
DataSource="CountryNames"
Placeholder="Please choose a country" />
@code {
protected List<CountryInfo> CountryNames;
protected override void OnInitialized()
{
this.CountryNames = CountryTreeData.Create();
}
}
Configuring Sorting Mode
사용자는 드롭다운에서 열의 헤더를 클릭하여 다중 열 콤보 박스에 표시되는 열을 정렬할 수 있습니다. 정렬 방식도 수정할 수 있는데, 열은 한 개의 열로만 정렬할 수 있고, 여러 열로 정렬할 수 있으며, 상승 및 하강 또는 삼중 상태로 제한될 수 있습니다. 이는 컴포넌트의 속성을 설정SortMode 함으로써 이루어집니다.
TriState 정렬 옵션을 사용하면 정렬된 열을 정렬 해제할 수 있습니다.
다음 코드는 다중 열 3상태별로 정렬할 수 있도록 다중 열 콤보 상자를 설정하는 방법을 보여줍니다.
<IgbMultiColumnComboBox Height="50px" Width="400px"
DataSource="CountryNames"
SortMode="SortMode.SortByMultipleColumnsTriState" />
@code {
protected List<CountryInfo> CountryNames;
protected override void OnInitialized()
{
this.CountryNames = CountryTreeData.Create();
}
}
API References
DataSourceFieldsGetValueAsyncGetValueIgbMultiColumnComboBoxPlaceholderSortModeTextFieldValueChangedValueField