UNPKG

jqwidgets-scripts-custom

Version:

jQWidgets is an advanced jQuery, Angular 7, Vue, React, ASP .NET MVC, Custom Elements and HTML5 UI framework.

38 lines (29 loc) 1.18 kB
import { Component, ViewChild, ElementRef, AfterViewInit } from '@angular/core'; import { jqxDropDownListComponent } from 'jqwidgets-scripts/jqwidgets-ts/angular_jqxdropdownlist'; @Component({ selector: 'app-root', templateUrl: './app.component.html' }) export class AppComponent implements AfterViewInit { @ViewChild('myDropDownList') myDropDownList: jqxDropDownListComponent; @ViewChild('select') select: ElementRef; updating: boolean = false; selectElement: HTMLSelectElement; ngAfterViewInit(): void { this.myDropDownList.loadFromSelect('select'); this.selectElement = this.select.nativeElement; this.selectElement.addEventListener('change', (event: any) => { this.updating = true; let index = this.selectElement.selectedIndex; this.myDropDownList.selectIndex(index); this.myDropDownList.ensureVisible(index); this.updating = false; }); } listOnSelect(event: any): void { if (event.args && !this.updating) { let index = event.args.item.index; this.selectElement.selectedIndex = index; } }; }