rowTemplate: kendo.template($("#rowTemplate").html()),
Thanks
6 Answers, 1 is accepted
Hello Alan,
You could add the template in a script block and compile it in a separate one. For example:
<script id=
"rowTemplate"
type=
"text/x-kendo-template"
>
...
</script>
<script>
var
myTemplate = kendo.template($(
'#rowTemplate'
).html());
</script>
Then you could use the compiled template variable in the Grid configuration:
.ClientRowTemplate(
"#=myTemplate(data)#"
)
I wish you a great day! Regards,
Dimiter Madjarov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Thanks
HI
I'm using external template, but Visual Studio Editor show the syntax warning in .cshtml -
"Attribut # already exists"
View(.cshtml)
HTML Element with dynamic attribute :
<script id="rowTemplate" type="text/x-kendo-template">
#
var loopRadioCheckedHtml = (loopRadioChecked) ? "checked='checked'" : ""; // HTML checked
#
<input type="radio" ... #= loopRadioCheckedHtml # ... />
#
...
#
</script>
*syntax warning for #= loopRadioCheckedHtml # (1st # char identified as attribute name, 2nd # char syntax warning).
May I ignore this syntax warning and is there have any side effects for view file execution ?
*There have no error after test.
Best regards
Chris
If the view engine compiles the view with no exceptions you should not face any trouble.
Nevertheless, if the warning bothers you, I can suggest you to override the default code analysis rules. Please refer to the following article for further information:
Regards,
Georgi
Progress Telerik