Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropdown Placeholder Capability #234

Closed
snowdave86 opened this issue Apr 21, 2016 · 8 comments
Closed

Dropdown Placeholder Capability #234

snowdave86 opened this issue Apr 21, 2016 · 8 comments
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@snowdave86
Copy link

Requesting new feature to be added to dropdown (placeholder capability). When using .push({ label: 'Select X', value: '' }); it will show the empty value option in the dropdown which is not true placeholder functionality.

@snowdave86 snowdave86 changed the title Feature Request: Dropdown Placeholder Capability [Feature Request] Dropdown Placeholder Capability Apr 21, 2016
@hhubik
Copy link

hhubik commented Oct 12, 2016

I second this. As an alternative or in addition to this, there should be a way to set the disabled attribute of one or more options to true. Perhaps the SelectItem interface could be extended to include an optional Disabled: boolean attributed with default of false.

@NishantHadole
Copy link

NishantHadole commented Nov 11, 2016

@snowdave86 @hhubik
Meanwhile, some workaround with little hack

export class ReportsComponent implements OnInit, AfterViewInit {

    reports: SelectItem[] = [];
    selectedReport;
    placeHolder: string = 'Select a Report';

    ngOnInit(): void {
        // populate reports
    }

    ngAfterViewInit(): void {
        this.hidePlaceHolder();

        let filterDivSelector: string = 'div.ui-dropdown-filter-container';
        jQuery(filterDivSelector).on('input', (event) => {
            this.hidePlaceHolder();
        });
    }

    hidePlaceHolder(): void {
        let placeHolderSelector: string = 'span:contains(' + this.placeHolder + ')';
        jQuery(placeHolderSelector).parent('li').hide();
    }
}

@sharok
Copy link

sharok commented Feb 26, 2017

@cagataycivici Could you provide this feature, I use autocomplete, simple input and dropdown controls on the same page and when controls don't have data, dropdown looks different without placeholder. For now, I use different dropdown control, but I don't want to have separate lib for this. Or, Do you have workaround for this?

@cagataycivici
Copy link
Member

I'm confused do you use autocomplete with dropdown option enabled or using p-dropdown?

@cagataycivici cagataycivici self-assigned this Feb 26, 2017
@cagataycivici cagataycivici added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Feb 26, 2017
@cagataycivici cagataycivici added this to the 2.0.2 milestone Feb 26, 2017
@sharok
Copy link

sharok commented Feb 26, 2017

I meant p-dropdown, because p-autoComplete has placeholder input.

@cagataycivici
Copy link
Member

What is the problem with { label: 'Select X', value: '' }? Isn't it how it's done with a native select element as well?

@cagataycivici cagataycivici changed the title [Feature Request] Dropdown Placeholder Capability Dropdown Placeholder Capability Feb 28, 2017
@sharok
Copy link

sharok commented Mar 1, 2017

@cagataycivici Yes, it's how native element works. I will show what I mean. For example, very popular select2 library. This is demo.
Another demo.

@cagataycivici
Copy link
Member

Got it, thanks for the pointer. I've added placeholder property for this functionality.

atretyak1985 added a commit to Nanitor/primeng that referenced this issue Jul 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

No branches or pull requests

5 participants