Using row Template in server side

2 posts, 1 answers
  1. VnDevil
    VnDevil avatar
    58 posts
    Member since:
    Oct 2012

    Posted 10 Nov 2015 Link to this post

    Hi Telerik,

     

    I'm usingASP.NET MVC Grid and I want using Column Template in server side but it's not working with my code:

    <div id="clientsDb">
        @(Html.Kendo().Grid<vw_Products>()
              .Name("grid")
              .Columns(columns =>
              {
                  columns.Template(item => "<img class='product-photo' src='" + ImageModel.GetThumbnail(item.Images) + "' alt='" + item.Title + "' /></td>")
                      .Width(140).Title("Picture");
                  columns.Bound(c => c.Title).Title("Product Name").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
                  columns.Bound(c => c.Price).Title("Price").Width(300).Filterable(ftb => ftb.Cell(cell => cell.Operator("gte")));
              })
              .HtmlAttributes(new { style = "height: 700px;" })
              .Scrollable()
              .Groupable()
              .Sortable()
              .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
              .Pageable(pageable => pageable
                  .Refresh(true)
                  .PageSizes(pageSizes)
                  .ButtonCount(5))
              .DataSource(dataSource => dataSource
                  .Ajax()
                  .PageSize(30)
                  .Read(read => read.Action("Products_Read", "Home"))
              )
        )
    </div>

    I think my set up is ok but it's not working, the column Template is Empty plz help me. Thanks

    columns.Template(item => "<img class='product-photo' src='" + ImageModel.GetThumbnail(item.Images) + "' alt='" + item.Title + "' /></td>")

     

  2. Answer
    Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 11 Nov 2015 Link to this post

    Hello,

    If the grid is ajax bound use the ClientTemplate method. The value should be a string which represents a valid Kendo Template.

    You can refer to this help article where more information is provided.

    Regards,
    Plamen
    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
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top