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

grid ClientTemplate

2 Answers 173 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 27 Mar 2014, 01:27 AM
Is it possible to add a grid inside a ClientTemplate for a column?   I would like to have a grid and then for one of the columns in the rows add another grid to it using the datasource.

It is like the example posted: http://demos.telerik.com/kendo-ui/web/grid/rowtemplate.html.  But, I want a grid in the column not the detailed grid example. 


2 Answers, 1 is accepted

Sort by
0
Andrew
Top achievements
Rank 1
answered on 27 Mar 2014, 03:46 PM
Here what I am tying to do.

### use the model from the grid to populate a partial view

@*@(Html.Kendo().Grid<GRMVC.Models.Buildings>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(e => e.buildingName).Width(120).Title("Building Name").ClientTemplate("#=buildingName#");
        columns.Bound(e => e.Items).Title("Testing").Template(p =>
             Html.Partial("~/Views/Shared/gridTemplates/_Column2.cshtml", p.Items).ToHtmlString()
        );
    })
   .DataSource(dataSource => dataSource
       .Ajax()
       .Read(read => read.Action("RegionGrid3Data", "Home"))
   )
)*@
               
### add a grid to a grid and get the data by AJAX.  I get a grid in the column, but no data.


@*@(Html.Kendo().Grid<GRMVC.Models.Buildings>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(e => e.buildingName).Width(120).Title("Building Name").ClientTemplate("#=buildingName#");
        columns.Bound(e => e.Items).Title("Testing").ClientTemplate(
             Html.Kendo().Grid<GRMVC.Models.Buildings>()
                .Name("grid")
                .Columns(col =>
                {
                    col.Bound(e => e.buildingName).Width(120).Title("Building Name");
                    col.Template(@<text></text>).Title("Testing").ClientTemplate("inside");
                })
                .HtmlAttributes(new { style = "min-height: 300px;" })
                .DataSource(dataSource => dataSource
                .Ajax()
                .Read(read => read.Action("RegionGrid3Data", "Home"))
                ).ToClientTemplate().ToHtmlString()
        );
    })
   .DataSource(dataSource => dataSource
       .Ajax()
       .Read(read => read.Action("RegionGrid3Data", "Home"))
   )
)*@

### use the model from the grid to populate a partial view

@*@(Html.Kendo().Grid<GRMVC.Models.Buildings>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(e => e.buildingName).Width(120).Title("Building Name").ClientTemplate("#=buildingName#");
        columns.Bound(e => e.Items).Title("Testing").Template(p =>
             @Html.Partial("~/Views/Shared/gridTemplates/_Column2.cshtml", p.Items).ToHtmlString()
        );
    })
   .DataSource(dataSource => dataSource
       .Ajax()
       .Read(read => read.Action("RegionGrid3Data", "Home"))
   )
)*@
0
Vladimir Iliev
Telerik team
answered on 28 Mar 2014, 04:01 PM
Hi Andrew,

Basically I would suggest to use Grid with client hierarchy as it will be more user friendly - please check the following example in our CodeLibrary:

Also you can use the same approach demonstrated in the above example to create a Grid inside column template.

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Andrew
Top achievements
Rank 1
Answers by
Andrew
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Share this question
or