You can prevent
selecting an item in Dropdown components by setting the cancel property as true in
the arguments of the select event. Also, you can show popup using showPopup method.
<div class="control-section">
<div class="col-lg-8 content-wrapper">
<ejs-dropdownlist
#sample
id="DDL"
[dataSource]="sportsData"
[fields]="fields"
[placeholder]="autoreactiveplaceholder"
floatLabelType="Auto"
(select)="onSelect($event)"
(close)="onClose($event)"
>
<ng-template #itemTemplate let-data>
<div [ngClass]="{ 'text-danger disabled': data.disabled }">
<span>{{ data.Game }}</span>
</div>
</ng-template>
</ejs-dropdownlist>
</div>
</div>
|
export class AppComponent {
@ViewChild('sample')
public listObj: DropDownListComponent;
public fields: Object = { text: 'Game', value: 'Id' };
public isBool: boolean = false;
public onSelect(args: any) {
if (args.itemData.disabled) {
args.cancel = true;
this.isBool = true;
}
}
public onClose(args: any) {
var that = this;
setTimeout(function () {
if (that.isBool) {
that.listObj.showPopup();
that.isBool = false;
} else {
that.listObj.hidePopup();
}
}, 300);
}
}
|
Sample : https://stackblitz.com/edit/angular-jggdft?file=app.component.ts,app.component.html