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

Concat String in Template

1 Answer 1784 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Oliver
Top achievements
Rank 1
Oliver asked on 30 May 2013, 01:52 PM
Hi There

Im using a Kendo Grid and want to show a joined array of strings.

# (ArrayOfStringsObject =! null) ? ArrayOfStringsObject.join() : SHOW "none" # <-- How can i show simple text in a template? 

Thanks

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 03 Jun 2013, 08:13 AM
Hello Oliver,

If we use the Kendo UI template expressions demo as a starting point, you have three options:

1. Return the desired output directly as plain HTML

2. Return the desired output as a string instead of returning a data field value


<script id="javascriptTemplate" type="text/x-kendo-template">
    <ul>
        # for (var i = 0; i < data.length; i++) { #
            # if (data[i] != "Second") { #
                <li>#= data[i] #</li>
            # } else { #
                <li> 1234567 #= "random string" # </li>
            # } #
        # } #
    </ul>
</script>


3. Create a new variable with the desired value and output it in the same way as a data field value:


<script id="javascriptTemplate" type="text/x-kendo-template">
    # var myArray = ([1, 2, 3]).join("") #
    #= myArray #
</script>


Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Oliver
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or