Using external templates in MVC grid

7 posts, 0 answers
  1. Alan Mosley
    Alan Mosley avatar
    200 posts
    Member since:
    Apr 2010

    Posted 10 Feb 2015 Link to this post

    What is the equivalent to this in MVC

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

    Thanks


  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2310 posts

    Posted 10 Feb 2015 Link to this post

    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.

     
  3. Alan Mosley
    Alan Mosley avatar
    200 posts
    Member since:
    Apr 2010

    Posted 10 Feb 2015 in reply to Dimiter Madjarov Link to this post

    bingo
    Thanks
  4. Alan Mosley
    Alan Mosley avatar
    200 posts
    Member since:
    Apr 2010

    Posted 10 Feb 2015 in reply to Dimiter Madjarov Link to this post

    bingo thanks
  5. Alan Mosley
    Alan Mosley avatar
    200 posts
    Member since:
    Apr 2010

    Posted 10 Feb 2015 in reply to Dimiter Madjarov Link to this post

    bingo thanks
  6. Chris
    Chris avatar
    119 posts
    Member since:
    Oct 2015

    Posted 03 Mar 2019 in reply to Dimiter Madjarov Link to this post

    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

     

     

  7. Georgi
    Admin
    Georgi avatar
    678 posts

    Posted 06 Mar 2019 Link to this post

    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.
Back to Top