RowTemplate and columns?

2 posts, 0 answers
  1. Ken De Vries
    Ken De Vries avatar
    24 posts
    Member since:
    Mar 2010

    Posted 21 Oct 2015 Link to this post

    Hi,

     I am trying to create a grid with one column to return a result similar to your example here: http://demos.telerik.com/kendo-ui/grid/rowtemplate.  I am using the server-side RowTemplate code such as...

                @(Html.Kendo().Grid(Model.Results)
                    .Name("Components")
                    .RowTemplate(grid =>
                        @<text>
                        <tr>
                            <td>
                                ID: @item.ComponentID<br>

                                Name: @item.Name

                                ... etc
                            </td>
                        </tr>
                        </text>
                    )

                .DataSource(d => d.Ajax().ServerOperation(false))
                .Pageable(pageable => pageable
                    .Refresh(true)
                    .PageSizes(true)
                    .ButtonCount(5))
                )

     I am basing my code on this example:

    @model IEnumerable<Product>@(Html.Kendo().Grid(Model).Name("grid")

        .RowTemplate(grid => @<text><div>Product Name: @product.ProductName</div><div>Units In Stock: @product.UnitsInStock</div></text>))

    ​The output completely ignores the rowFormat and prints every field in the model object as a separate column (see attached photo).

    I have tried almost everything - client templates, etc.  Nothing stops every column from being displayed.

     Any ideas would be appreciated.

  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 22 Oct 2015 Link to this post

    Hello Ken,

    The current Grid uses an Ajax DataSource, meaning that a client row template should be used instead. You could find the MVC equivalent of the demo here.

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