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

Add emptyMessage property to Dropdown #2062

Closed
sriharsha0312 opened this issue May 24, 2021 · 2 comments
Closed

Add emptyMessage property to Dropdown #2062

sriharsha0312 opened this issue May 24, 2021 · 2 comments
Assignees
Labels
Type: New Feature Issue contains a new feature or new component request
Milestone

Comments

@sriharsha0312
Copy link

When no options are present in dropdown , we need to get a panel with message 'No results found' which should not be clickable. Following are the two scenarios
1.If filter={false} passed to dropdown no options will be present in that dropdown ,so we need to get a panel with message 'No results found'.
image
2. By passing filter={true} to dropdown incase no options were present in the dropdown we need to get the panel with same message.
image
3.We also need to get a loader for the panel,when it takes some time to bind response data to the dropdown.

Thanks in Advance

@segocago
Copy link

segocago commented May 25, 2021

You can pass a no results option as options to dropdown component when there are no options.

<Dropdown options={yourOptions.length > 0 ? yourOptions : [{label:"No results found",value:"No results found",disabled:true}]} ...restOfProps/>

@mertsincan mertsincan changed the title Dropdown panel issue when options are empty Add emptyMessage property to Dropdown Jun 10, 2021
@mertsincan mertsincan self-assigned this Jun 10, 2021
@mertsincan mertsincan added the Type: New Feature Issue contains a new feature or new component request label Jun 10, 2021
@mertsincan mertsincan added this to the 6.4.0 milestone Jun 10, 2021
@mertsincan
Copy link
Member

mertsincan commented Jun 10, 2021

Hi,

Added emptyMessage property to Dropdown. You can use it like;

emptyMessage="Test"

emptyMessage={<span>Test</span>}

emptyMessage={(props) => <span>Test</span>}

3.We also need to get a loader for the panel,when it takes some time to bind response data to the dropdown.

You can do it using the conditional JSX element in emptyMessage. Exp;

emptyMessage={loading ? <div><i className="pi pi-spin pi-spinner" style={{'fontSize': '2em'}}></i><div> : <span>No records found</span>}

Best Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: New Feature Issue contains a new feature or new component request
Projects
None yet
Development

No branches or pull requests

3 participants