kendoMultiSelectTagTemplate template reference to dataItems collection

2 Answers 111 Views
MultiSelect
Marvin
Top achievements
Rank 1
Iron
Iron
Marvin asked on 22 Apr 2022, 02:34 PM | edited on 22 Apr 2022, 02:36 PM

Hello,

The kendoMultiSelectTagTemplate exposes each item via its dataItem (singular) template reference.

Is there a way it can also access the dataItems (plural) collection?

I would like to display a full length description in each tag when fewer items are selected, and a shorter, abbreviated description when more items are selected.

Note that I am already using the kendoMultiSelectSummaryTag when many, many items are selected, but this is expected to rarely occur with my users.  Most often only 1 or 2 items will be selected in which case I want the longer descriptions.  Occasionally, 2 - 10 items will be selected and in that case I want the abbreviations.  And with more than 10, I'll show the summary tag.

Thanks!

2 Answers, 1 is accepted

Sort by
0
Accepted
Marvin
Top achievements
Rank 1
Iron
Iron
answered on 22 Apr 2022, 02:53 PM

I figured it out.  The template reference variable on the component itself is available so that seems to be working.

<kendo-multiselect #myMultiSelect>
  <ng-template kendoMultiSelectTagTemplate let-dataItem>
    {{ myMultiSelect.value.length < 3 ? dataItem.longName : dataItem.shortName }}
  </ng-template>
</kendo-multiselect>

1
Stefani
Telerik team
answered on 27 Apr 2022, 09:24 AM

Hello Marvin,

Thank you for the details.

I'm glad you were able to resolve this yourself. Indeed, the shared implementation is a proper way to access the MultiSelect component's value.

Additionally, all public fields of the component class where the MultiSelect is used can be accessed inside the template.

Regards,
Stefani
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
MultiSelect
Asked by
Marvin
Top achievements
Rank 1
Iron
Iron
Answers by
Marvin
Top achievements
Rank 1
Iron
Iron
Stefani
Telerik team
Share this question
or