Angular UI Components Documentation

Angular ComboBox Component

The ComboBox component for Angular contains an input field with auto-complete functionality and a list of selectable items displayed in a drop-down.

1. Installation

The easiest way to get started with jQWidgets UI for Angular is to use the Angular CLI Tool. To scaffold your project structure, follow its installation instructions.

npm install -g @angular/cli
ng new jqwidgets-project
cd jqwidgets-project

Install jQWidgets

jQWidgets Angular UI comes packaged with Angular CLI schematics to make creating Angular applications easier. Schematics are included with both @angular/cdk and jqwidgets-ng. Once you install the npm packages, they will be available through the Angular CLI.

Angular CLI supports the addition of packages through the ng add command. The ng add command provides faster and more user-friendly package installation. To install the jQWidgets UI for Angular package, use ng add and add the name of the NPM package:

ng add jqwidgets-ng

Alternatively, you can use the standard installation (Manual Setup)

jQWidgets UI for Angular is distributed as jqwidgets-ng NPM package

  1. Download and install the package.
    npm install jqwidgets-ng
  2. Adding CSS reference

    The following CSS file is available in ../node_modules/jqwidgets-ng/ package folder. This can be referenced in [src/styles.css] using following code.

    @import 'jqwidgets-ng/jqwidgets/styles/jqx.base.css';

    Another way to achieve the same is to edit the angular.json file and in the styles add the style.

    "styles": [
    	"node_modules/jqwidgets-ng/jqwidgets/styles/jqx.base.css"
    ]
    

2. Add the HTML for jQWidgets component in src/app/app.component.html

app.component.html


<jqxComboBox [theme]="'fluent'" 
    [width]='250' [height]='25' 
    [source]='source' [selectedIndex]='0'>
</jqxComboBox>	

3. Setup Component Logic

app.component.ts


import { Component, ViewChild } from '@angular/core';

import { jqxComboBoxModule, jqxComboBoxComponent } from 'jqwidgets-ng/jqxcombobox';
@Component({
    selector: 'app-root',
    imports: [jqxComboBoxModule],
    standalone: true,
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css'],
    encapsulation: ViewEncapsulation.None
})

export class AppComponent {
    source: any[] = this.generateHTML();

    generateHTML(): any[] {
        let source = new Array();

        for (let i = 0; i < 10; i++) {
            let movie = 'avatar.png';
            let title = 'Avatar';
            let year = 2009;
            switch (i) {
                case 1:
                    movie = 'endgame.png';
                    title = 'End Game';
                    year = 2006;
                    break;
                case 2:
                    movie = 'priest.png';
                    title = 'Priest';
                    year = 2011;
                    break;
                case 3:
                    movie = 'unknown.png';
                    title = 'Unknown';
                    year = 2011;
                    break;
                case 4:
                    movie = 'unstoppable.png';
                    title = 'Unstoppable';
                    year = 2010;
                    break;
                case 5:
                    movie = 'twilight.png';
                    title = 'Twilight';
                    year = 2008;
                    break;
                case 6:
                    movie = 'kungfupanda.png';
                    title = 'Kung Fu Panda';
                    year = 2008;
                    break;
                case 7:
                    movie = 'knockout.png';
                    title = 'Knockout';
                    year = 2011
                    break;
                case 8:
                    movie = 'theplane.png';
                    title = 'The Plane';
                    year = 2010;
                    break;
                case 9:
                    movie = 'bigdaddy.png';
                    title = 'Big Daddy';
                    year = 1999;
                    break;
            }
            let html = "<div style='padding: 0px; margin: 0px; height: 95px; float: left;'><img width='60'" +
                "style='float: left; margin-top: 4px; margin-right: 15px;' src='https://www.jqwidgets.com/angular/images/" + movie
                + "'/><div style='margin-top: 10px; font-size: 13px;'>" + "<b>Title</b><div>" + title +
                "</div><div style='margin-top: 10px;'><b>Year</b><div>" + year.toString() + "</div></div></div>";
            source[i] = { html: html, title: title };
        }
        return source;
    }
}

Summary

jQWidgets UI for Angular provides an easy way to integrate robust UI components into your Angular project. By using either the ng add command or manual setup, you can quickly get started. Once the setup is complete, you can add the desired jQWidgets components and configure them in your Angular components to match your application requirements.

ComboBox API

API Reference of the jQWidgets ComboBox component for Angular: ComboBox API