Having trouble getting help?
Contact Support
Contact Support
Group header in Angular Drop down list component
27 Apr 20243 minutes to read
The following example demonstrate about how to disable the Fixed group header in DropDownList through CSS by using visibility
attribute.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { FormsModule } from '@angular/forms'
import { DropDownListModule } from '@syncfusion/ej2-angular-dropdowns'
import { Component } from '@angular/core';
@Component({
imports: [
FormsModule, DropDownListModule
],
standalone: true,
selector: 'app-root',
// specifies the template string for the DropDownList component
template: `<ejs-dropdownlist id='ddlelement' #samples [dataSource]='data' [fields]='fields' [placeholder]='text' [popupHeight]='height'></ejs-dropdownlist>`,
})
export class AppComponent {
constructor() {
}
// defined the array of data
public data: { [key: string]: Object }[] = [
{ Vegetable: 'Cabbage', Category: 'Leafy and Salad', Id: 'item1' },
{ Vegetable: 'Spinach', Category: 'Leafy and Salad', Id: 'item2' },
{ Vegetable: 'Wheat grass', Category: 'Leafy and Salad', Id: 'item3' },
{ Vegetable: 'Yarrow', Category: 'Leafy and Salad', Id: 'item4' },
{ Vegetable: 'Pumpkins', Category: 'Leafy and Salad', Id: 'item5' },
{ Vegetable: 'Chickpea', Category: 'Beans', Id: 'item6' },
{ Vegetable: 'Green bean', Category: 'Beans', Id: 'item7' },
{ Vegetable: 'Horse gram', Category: 'Beans', Id: 'item8' },
{ Vegetable: 'Garlic', Category: 'Bulb and Stem', Id: 'item9' },
{ Vegetable: 'Nopal', Category: 'Bulb and Stem', Id: 'item10' },
{ Vegetable: 'Onion', Category: 'Bulb and Stem', Id: 'item11' }];
// maps the appropriate column to fields property
public fields: Object = { groupBy: 'Category', text: 'Vegetable', value: 'Id' };
// set the placeholder to the DropDownList input
public text: string = "Select a vegetable";
// Set the popup list height
public height: string = '200px';
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));