| title | Combo Features |
|---|---|
| description | Combo control exposes several of features including data and value binding, custom values, filtering, grouping, etc. |
| keywords | Ignite UI for Angular, UI controls, Angular widgets, web widgets, UI widgets, Angular, Native Angular Components Suite, Native Angular Controls, Native Angular Components Library, Angular Combo components, Angular Features, Angular Combo Features, Angular Combo Data Binding, Angular Combo Value Binding, Angular Combo Data Filtering, Angular Combo Grouping, Angular Combo Custom Values |
| _language | kr |
Combo control exposes several features including data and value binding, custom values, filtering, grouping, etc.
The following demo demonstrates some of the combo features that are enabled/disabled at runtime:
To get started with the Ignite UI for Angular Combo import the IgxComboModule in the app.module.ts file. For the following sample the igx-switch component is used and in addition we will need the IgxSwitchModule also:
// app.module.ts
...
import { IgxComboModule, IgxSwitchModule } from 'igniteui-angular';
@NgModule({
...
imports: [..., IgxComboModule, IgxSwitchModule],
...
})
export class AppModule {}The demo uses igx-switch component to toggle igx-combo properties' values. Note that grouping is enabled/disabled by setting groupKey to corresponding data source entity or setting it to empty string.
<div class="combo-container">
<igx-combo #combo [data]="lData" [displayKey]="'field'" [valueKey]="'field'"
[allowCustomValues]="customValues"
[filterable]="filterable"
[disabled]="disabled">
</igx-combo>
</div>
<div class="switch-container">
<igx-switch [(ngModel)]="filterable">Enable Filtering</igx-switch><br />
<igx-switch [(ngModel)]="customValues">Allow Custom Values</igx-switch><br />
<igx-switch (change)="enableGroups($event)">Enable Grouping</igx-switch><br />
<igx-switch [(ngModel)]="disabled">Disabled</igx-switch>
</div> @ViewChild("combo", { read: IgxComboComponent }) public combo: IgxComboComponent;
public filterable = true;
public customValues = true;
public disabled = false;
public enableGroups(event) {
this.combo.groupKey = event.checked ? "region" : "";
}Basic usage of igx-combo bound to a local data source, defining valueKey and displayKey:
<igx-combo [data]="lData" [valueKey]="'ProductID'" [displayKey]="'ProductName'"></igx-combo>import { localData } from "./local-data";
export class ComboDemo implements OnInit {
public lData: any[];
public ngOnInit() {
this.lData = localData;
}
}Note: If displayKey is omitted then valueKey entity will be used instead.
Follow this topic for more details about binding igx-combo with remote data.
For two-way data-binding, the ngModel can be used like shown below:
<igx-combo #combo [data]="data" [(ngModel)]="values"></igx-combo>export class MyExampleComponent {
...
public data: ExampleType[] = ...;
...
public values: ExampleType[] = ...;
}By default filtering in the combo is enabled. It can be disabled using the following code:
<igx-combo [filterable]="false"></igx-combo>If the custom values are enabled, the missing item could be added using the UI of the combo.
<igx-combo [allowCustomValues]="true"></igx-combo>You can disable combo using the following code:
<igx-combo [disabled]="true"></igx-combo>Defining a combo's groupKey option will group the items, according to the provided key.
<igx-combo [groupKey]="'primaryKey'"></igx-combo>- IgxComboComponent API Reference and Themes Reference.
- Combo Remote Binding
- Combo Templates
- Template Driven Forms Integration
- Reactive Forms Integration
- Single Select ComboBox
- IgxSwitch
Our community is active and always welcoming to new ideas.