Is there a selection state in DropDownButton?

Hi!

Well, as the title says, there is a selection state in dropDownButton or a way to replacte it? I did not see anything in https://ej2.syncfusion.com/angular/documentation/drop-down-button/getting-started/


FYI: 

Selection state: Indicates which item is selected with an icon (normally a check) once you open the list

Ref: https://material.io/components/menus#anatomy

Thanks.


1 Reply 1 reply marked as answer

YA YuvanShankar Arunagiri Syncfusion Team September 12, 2022 09:18 AM UTC

Hi Tomas,


We have validated your reported query and prepared the sample based on your requirement. please refer the code snippet and sample link. We can achieved your requirement by using the beforeItemRender and select event of the dropdown button with CSS.

[app.component.ts]:

OnRender(args) {

        args.element.children[0].classList.add('e-hide');

        if (this.selectedItem !== "" && args.item.text === this.selectedItem) {

            args.element.children[0].classList.remove('e-hide');

        }

    }

 

    select(args) {

        this.selectedItem = args.item.text;

    }


Sample link: https://stackblitz.com/edit/angular-dtxxwc?file=app.component.ts

Could you please check with the above code and get back to us, if you need any further assistance on this.


Regards,

YuvanShankar A


Marked as answer
Loader.
Up arrow icon