Skip to content

[Select] Custom text for multiple selected values #6218

Closed

Description

@davidreher

Bug, feature request, or proposal:

Feature request: Make it possible to adjust the text which is shown if multiple values are selected in MdSelect.

What is the expected behavior?

When all values are selected, the text is "[all] selected.
When more than 2 values are selected the text is "2 selected".

What is the current behavior?

All values are shown, seperated by ,, if they won't fit, ellipses are applied.

What are the steps to reproduce?

Go to the plunk and select all values.

What is the use-case or motivation for changing an existing behavior?

To our customers it is more useful to see how many values are selected (whether or not all are selected), rather than seeing only the first part of the text of the first selected item.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

master

Is there anything else we should know?

I already tried extending MdSelect. I think this is the best option, but I got stuck on all the errors in the (copied) template :(

Another option would be to have a callback as input property which is evaluated as part of triggerValue upon changes ...

I can also work on a PR if this is something which is required by others as well and if you have some guidance on the best option ...

Activity

  1. willshowell commented on Aug 2, 2017

    @willshowell
    Contributor

    Duplicate of #2275

  2. davidreher commented on Aug 2, 2017

    @davidreher
    Author

    I think this is somewhat different. Does it really solve my issue if I can specify how the selected values should be rendered? Still they will be concatenated or do I get it wrong?

  3. willshowell commented on Aug 2, 2017

    @willshowell
    Contributor

    Yeah I see the distinction now, good call. I know I'd seen a similar request (#2722 (comment)) but it doesn't look like there's issue tracking for it yet!

  4. davidreher commented on Aug 2, 2017

    @davidreher
    Author

    @willshowell: Any ideas on the implementation? What would fit best? Should the text be included by material and then i18n-ized or should we have a callback?

  5. willshowell commented on Aug 2, 2017

    @willshowell
    Contributor

    I feel like a callback similar to autocomplete's displayWith is very comparable and makes sense for this. But if the default changes to "x, y, and 4 others" then it would certainly require internationalization.

  6. added 3 commits that reference this issue on Aug 2, 2017
    93253b0
    b50b225
    a81b54d
  7. davidreher commented on Aug 8, 2017

    @davidreher
    Author

    will be fixed by #3341

  8. angular-automatic-lock-bot commented on Sep 6, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  9. locked and limited conversation to collaborators on Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions