Hi Team,
In a dropdownlist after selecting before changing the value we need to show a confirmation popup if clicked on 'OK' in that popup we need to change value if clicked on 'NO' we need to revert that change.
this is the sample code snippet
Can you please provide me a solution for this issue.
Thank you,
Lahari Navudu
Hi Lahari,
We can show a confirmation popup while we select any item in the DropDownList popup using the select event and confirm() method. The confirm() method displays a dialog box with a message, an OK button, and a Cancel button. The confirm() method returns true if the user clicked "OK", otherwise false. Based on the confirmation we can prevent the selection of an item on the DropDownList component.
export class AppComponent { @ViewChild('sample') public listObj: DropDownListComponent; public sportsData: Object[] = [ { Id: 'Game1', Game: 'American Football' }, { Id: 'Game2', Game: 'Badminton' }, { Id: 'Game3', Game: 'Basketball' }, { Id: 'Game4', Game: 'Cricket' }, ]; public fields: Object = { text: 'Game', value: 'Id' }; public height: string = '220px'; public waterMark: string = 'Select a game'; public value: string = ''; public onSelect(args) { let text = 'Click OK to Confirm the Change'; if (confirm(text) == false) { args.cancel = true; } } } |
Sample : https://stackblitz.com/edit/angular-yjxzxj?file=app.component.html,app.component.ts
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Udhaya Kumar D