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

MultiColumnComboBox Template Column

3 Answers 65 Views
Documentation and Tutorials
This is a migrated thread and some comments may be shown as answers.
Wally
Top achievements
Rank 1
Wally asked on 10 Mar 2020, 03:29 PM

I'm looking at the tutorial (https://demos.telerik.com/aspnet-ajax/multicolumncombobox/overview/defaultvb.aspx) and it uses a form of the ASP Embedded Code Blocks to reference the data source column.  Is it possible to use conditionals in this code, i.e. If clauses, so that the template can be customized based on the value?  I'd like to use it for an address to only show the comma separating Address Line 1 and Line 2 when Line 2 is not null/empty (so you don't have an extraneous comma at the end of the street address).  I tried the following code but it doesn't work (the drop-down never appears)

<span>#: Vendor_Address_1 #</span><span>#: If(Vendor_Address_2="","",", " & Vendor_Address_2) #</span>

3 Answers, 1 is accepted

Sort by
0
Accepted
Vessy
Telerik team
answered on 13 Mar 2020, 07:48 AM

Hi Wally,

All client templates of the the MultiColumnCombobox (and the other Kendo UI wrappers in the UI for ASP.NET AJAX suite) allow the usage of JavaScript logic, so you can add a simple condition setting different template depending on the desired criteria. Each JavaScript line has to be wrapped in ## signs, which the values that has to be rendered with #: # or #= #. You can find detailed information about the Kendo templates syntax here:

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

The logic inside the templates is accepting JavaScript syntax, which is case sensitive so you have to make sure that the proper casing is used (in the provided snippet If has a capital I ). In order to render something on specific condition, you will need to put the desired output in the body of the If statement.

For example, you can use the following template as a base for your implementation:

                        <Template>
                            <span>#: Vendor_Address_1 #</span>
                                # if(Vendor_Address_2 && Vendor_Address_2 != "" && Vendor_Address_2 != null) {#
                                    <span>#: Vendor_Address_2 #</span>
                                #}#
                        </Template>

Regards,
Vessy
Progress Telerik

Get quickly onboarded and successful with UI for ASP.NET AJAX with the Virtual Classroom technical trainings, available to all active customers. Learn More.
0
Wally
Top achievements
Rank 1
answered on 13 Mar 2020, 01:15 PM
Oh, I didn't realize it was a Kendo control.  Thank you!
0
Vessy
Telerik team
answered on 16 Mar 2020, 06:40 AM

Hi,

You are welcome, Wally - I am glad my reply was helpful for you :)

Regards,
Vessy
Progress Telerik

Get quickly onboarded and successful with UI for ASP.NET AJAX with the Virtual Classroom technical trainings, available to all active customers. Learn More.
Tags
Documentation and Tutorials
Asked by
Wally
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Wally
Top achievements
Rank 1
Share this question
or