Completed
Last Updated: 03 Sep 2024 07:23 by ADMIN
Petr
Created on: 15 Aug 2024 14:14
Category: ComboBox
Type: Feature Request
0
Configurable template for ComboBoxComponent

Hello!

I think it will be nice to have configurable template for ComboBoxComponent input field.

something like it is possible within grid pager comes to my mind - there is a template and building blocks that we can use


Use case:

For example, in our work we customize item template with



and our customers wish to see selected item as it is in the list, with icon and other customizations.


I have managed to do that by creating a directive that i put on <kendo-combobox>... and that inserts dynamically created icon component near the input, so that it looks same as in the options list.

But this is ugly and not easy maintainable, etc 



4 comments
Petr
Posted on: 30 Aug 2024 14:43
Thank you for info, Martin,

this was really interesting to know! We somehow messed this prefix thing from the documentation, maybe we will use it later in our work.

There is no urge - i have already implemented it myself for our needs, as i have shown in the original post, so it was mostly just to let you all know about possible improvement point
ADMIN
Martin Bechev
Posted on: 30 Aug 2024 12:01

Hi Petr,

Thank you for providing additional details for this case.

If I understand correctly, you are requesting an option to customize the selected value on the component, the same as kendoDropDownListValueTemplate works for the DropDownList:

https://www.telerik.com/kendo-angular-ui/components/dropdowns/dropdownlist/templates/#toc-value-template

Please correct me if I am wrong.

The main difference between DropDownList and ComboBox is that the ComboBox internally has an <input /> element which allows the user to type in, while the DropDownList doesn't. That was the main reason for not providing such a template for the ComboBox.

What can be done instead is to explore the prefix adornments that allow rendering any custom HTML beside the ComboBox value:

https://www.telerik.com/kendo-angular-ui/components/dropdowns/combobox/adornments/#toc-prefix-adornments

Another possible to achieve the desired end result is to replace the ComboBox with DropDownList (if the application requirements allow it).

Please check it out and let me know in case any further questions arise.

Regards,
Martin Bechev
Progress Telerik

Do you have a stake in the designеr-developer collaboration process? If so, take our survey to share your perspective and become part of this global research. You’ll be among the first to know once the results are out.
-> Start The State of Designer-Developer Collaboration Survey 2024

Petr
Posted on: 26 Aug 2024 07:39

Hello, Martin,

Thank you for your answer. 

We are indeed using the kendoComboBoxItemTemplate to configure the item in the list (i marked the place with green)

 

The problem is that this template is applied only to the item in the dropdown(greed), not to the selected item box - marked with red.

That is what this feature request is about - about configuring the template for selected item. I have created a workaround for ourselves, i "manually" push desired content into the DOM, as it is not configurable in any other way.




ADMIN
Martin Bechev
Posted on: 21 Aug 2024 10:46

Hello Petr,

I am not sure that understand the feature correctly and what is the desired outcome.

In case the ComboBox options should also have an icon beside it, the developer can add the icon in the template along with the text, like:

                <ng-template kendoComboBoxItemTemplate let-dataItem>
                    <kendo-svg-icon [icon]="icons.paperclip"></kendo-svg-icon>
                    {{ dataItem.text }}
                </ng-template>

The only difference is the generated DOM is that in the default ComboBox (no template) the text is wrapped into a span with the class "k-list-item-text" which can be also done in the template:

     <ng-template kendoComboBoxItemTemplate let-dataItem>
                    <kendo-svg-icon [icon]="icons.paperclip"></kendo-svg-icon>
                    <span class="k-list-item-text">{{ dataItem.text }}</span>
                </ng-template>

Here is an example where different icons are rendered beside the options:

https://stackblitz.com/edit/angular-sjgeu4

Please check out the demo and let us know if we misunderstand the query.

Regards,
Martin Bechev
Progress Telerik

Do you have a stake in the designеr-developer collaboration process? If so, take our survey to share your perspective and become part of this global research. You’ll be among the first to know once the results are out.
-> Start The State of Designer-Developer Collaboration Survey 2024