This is a migrated thread and some comments may be shown as answers.

Format Columns in List

2 Answers 15 Views
MultiColumnComboBox
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Veteran
Patrick asked on 08 Mar 2021, 06:02 PM

Hello,

I'm using the MultiColumnComboBox as an editor w/in a Telerik Grid. One of the columns in the underlying model I used a display format attribute, [DisplayFormat(DataFormatString = "{0:#,##0.##;(#,##0.##)}")] that isn't coming through in the MultiColumnComboBox dropdown list. A second column is a percentage, [DisplayFormat(DataFormatString = "{0:P3}")] where, again, the display format isn't carried through to the widget. Can you explain to me how I can format the columns of the MultiColumnComboBox, please? I'd also like to align these values to the right. I used the HeaderTemplate to align the header to the right, but the column cell values align to the left.

Regards,

Patrick

2 Answers, 1 is accepted

Sort by
0
Patrick
Top achievements
Rank 1
Veteran
answered on 09 Mar 2021, 03:25 PM

Looking at the MultiComboBox API documentation I see there is a Template method. So I tried the formatting below for the numeric value w/comma separators (I didn't try it w/\\#\\,\\#\\#0.00;\\(\\#\\,\\#\\#0.00)' to see if it could format negative #s in parens as there would be no negatives in this use case) and it seemed to work:

     .Template("<div style='text-align:right;'>#= Principal? " +
                                    "kendo.toString(Principal, '\\#\\,\\#\\#0.00') : " +
                                    "'' #</div>")

 

For the column to display a percentage, this seemed to work:

.Template("<div style='text-align:right;'>#= CouponRate? " +
                                "kendo.toString(CouponRate, 'P3') : " +
                                "'' #</div>");

Can you let me know whether there is a better, more intuitive way to accomplish the formatting of the columns? Can you point me to either documentation of what can be done with the Template method as the API documentation simply says "Renders a template for the column"? Or if there's not more comprehensive documentation of it, can you point me to examples of different ways of using the Template method?

0
Aleksandar
Telerik team
answered on 11 Mar 2021, 02:54 PM

Hi Patrik,

Indeed in order to achieve the desired result you should use a template. All of the # symbols that are not pare of the template syntax should be escaped. For details on Kendo Templates and the template syntax you can refer to the documentation here: 

https://docs.telerik.com/kendo-ui/framework/templates/overview

I hope this helps.

Regards,
Aleksandar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
MultiColumnComboBox
Asked by
Patrick
Top achievements
Rank 1
Veteran
Answers by
Patrick
Top achievements
Rank 1
Veteran
Aleksandar
Telerik team
Share this question
or