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

Using external templates in MVC grid

6 Answers 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alan Mosley
Top achievements
Rank 1
Alan Mosley asked on 10 Feb 2015, 07:56 AM
What is the equivalent to this in MVC

rowTemplate: kendo.template($("#rowTemplate").html()),

Thanks


6 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 10 Feb 2015, 11:45 AM

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.

 
0
Alan Mosley
Top achievements
Rank 1
answered on 10 Feb 2015, 11:50 AM
bingo
Thanks
0
Alan Mosley
Top achievements
Rank 1
answered on 10 Feb 2015, 11:51 AM
bingo thanks
0
Alan Mosley
Top achievements
Rank 1
answered on 10 Feb 2015, 11:53 AM
bingo thanks
0
Chris
Top achievements
Rank 1
Veteran
Iron
answered on 04 Mar 2019, 05:25 AM

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

 

 

0
Georgi
Telerik team
answered on 06 Mar 2019, 06:13 AM
Hello 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
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Alan Mosley
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Alan Mosley
Top achievements
Rank 1
Chris
Top achievements
Rank 1
Veteran
Iron
Georgi
Telerik team
Share this question
or