ClientRowTemplate with external template

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

    Posted 23 Jul 2015 Link to this post

    I want to use ClientRowTemplate with external template but cant seem to reference it

    .ClientRowTemplate(  what goes here   ) 

    how to do . thanks

    <script id="cart-grid-template" type="text/x-kendo-template">
    ...
    </script>

  2. eo
    eo avatar
    27 posts
    Member since:
    Jul 2015

    Posted 24 Jul 2015 in reply to Alan Mosley Link to this post

    Hello Alan,

    To reference an external template you need to use its id like this:

    var externalTemplateContent = $("#cart-grid-template").html();​

    After that you should be able to call .clientRowTemplate(externalTemplateContent)

  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Alan Mosley
    Alan Mosley avatar
    200 posts
    Member since:
    Apr 2010

    Posted 24 Jul 2015 in reply to eo Link to this post

    I did see that and tried it, I ended up doing something else, but will try your solution again next time, thanks
  5. eo
    eo avatar
    27 posts
    Member since:
    Jul 2015

    Posted 24 Jul 2015 Link to this post

    Glad you solved it already, could you share the solution that worked for you?

    Thanks

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

    Posted 24 Jul 2015 in reply to eo Link to this post

    I was converting a site from the old mvc wrappers to Kendo and had trouble with one grid with heaps of inline template hard to maintain, in the end I used listview, it has all I need to replace the grid and has ClientTemplateId,  Thanks
  7. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 27 Jul 2015 Link to this post

    Hello guys,

    In order to use an external template as client or client row template, you could compile it via the kendo.template method.
    E.g.

    <script id="columnTemplate" type="text/x-kendo-template">
        ...
    </script>
      
    <script>
        var myTemplate = kendo.template($('#columnTemplate').html());
    </script>

    .ClientRowTemplate("#=myTemplate(data)#");

    Regards,
    Dimiter Madjarov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET MVC is VS 2017 Ready