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

Feature: sublabels / option slots #8

Closed
ernestoalejo opened this issue Nov 5, 2017 · 5 comments
Closed

Feature: sublabels / option slots #8

ernestoalejo opened this issue Nov 5, 2017 · 5 comments

Comments

@ernestoalejo
Copy link

I would like to customize the options adding a new gray sublabel, like count but with my own text. The best solution would probably be a slot that allows the users of this component to change the labels with our own custom HTML:

<treeselect ...>
  <template slot="option" slot-scope="option">
    {{option.label}}
    ...other things i want to customize the label with here...
  </template>
</treeselect>

You can provide a default slot implementation as a fallback, so it's a completely backwards compatible change and only adds new functionality.

@riophae
Copy link
Owner

riophae commented Nov 5, 2017

I totally agree. Thanks for your feedback!

@riophae
Copy link
Owner

riophae commented Nov 6, 2017

Hey, I just added the slot. It would be like this to use it:

<treeselect ...>
  <template slot="option" slot-scope="{ option }">
    {{option.label}}
    ...other things i want to customize the label with here...
  </template>
</treeselect>

Note that, slot-scope="{ option }" used destructuring. The option variable provides a lot of properties (e.g. isBranch, isLeaf, ancestors, level, ...etc) for your template to consume. You can also use option.raw to access the original option data you passed to the component.

Another thing worth noting is that, since the count text is implemented in the fallback content, if you customized the slot then you have to implement the count text yourself too if you are using it.

Do you think the API design fits your needs? Any suggestions are welcome!

@anfinil
Copy link

anfinil commented Nov 15, 2017

Any chance to release a new version?

@riophae
Copy link
Owner

riophae commented Nov 15, 2017

@anfinil I'm sorry, it's not done yet :(

@riophae
Copy link
Owner

riophae commented Mar 7, 2018

Hi, really sorry it took too long to have this feature finished. Just to let you know I just shipped it in v0.0.7.

@riophae riophae closed this as completed Mar 7, 2018
MichalWi pushed a commit to MichalWi/vue-treeselect that referenced this issue Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants