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

Using external template with ASP.Net MVC helper

1 Answer 358 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kent
Top achievements
Rank 1
Kent asked on 06 Feb 2013, 04:58 PM
Is there a way to use an external kendo template when using the ASP.Net MVC grid helper?


Here's my template:
<script id="javascriptTemplate" type="text/x-kendo-template">
    var isToday = true;
 
    #if(isToday){#
        // show time only e.g. 1:04 PM
    #}else{#
        // show date and time e.g. 02/06/2013 1:04 PM
    #}#
</script>

And I want to use that template in my grid:
@(Html.Kendo().Grid<SiteItem>()
      .Name( "sitesgrid" )
      .Columns( columns =>
                    {
                        columns.Bound( s => s.LastReport ).ClientTemplate( "javascriptTemplate" );
                    }
      )
      .DataSource( ds => ds
                             .Ajax().Read( "SitesGrid", "Dashboard" )
                             .PageSize( 10 )
                             .Sort( sort => sort.Add( p => p.SiteName ) )
      )
      .Pageable( pager => pager
                              .Messages( messages => messages.Display( "{0} - {1} of {2} sites" ) )
      )
      .Filterable()
      .Sortable()
      .Selectable()
      .ColumnMenu()
      .Events( events => events.Change( "onSitesGridSelect" ) )
      .Events( events => events.DataBound( "onGridDatabound" ) )
      )

Is this possible? With the pasted code, it simply outputs the word "javascriptTemplate"


1 Answer, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 07 Feb 2013, 01:38 PM
Tags
Grid
Asked by
Kent
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or