I am looking for a way (if there is any) to use data retrieved from the datasource, inside the template, as javascript.
Let me clarify...
In my datasource results i have a variable called ItemType.
In a template i would use this variable using ${ItemType} to 'echo' it in the page.
You can use javascript inside the template by using # if (...) { console.log('test') } #.
What i want to achieve, is to use the ${ItemType} inside the template's javascript like this:
<script type="text/x-kendo-tmpl" id="dossier_template">
# var type= "${ItemType} "; #
If i can set a variable depending on the datasource item, i can use if-statements within the rest of the template like this:
# if(type == '1') {#
<div class="type_one"></div>
# else { #
<div class="type_two"></div>
#
You can try this:
# var type= ItemType; #
This should also work:
# if(ItemType == '1') {#
<div class="type_one"></div>
# else { #
<div class="type_two"></div>
#
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With