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

Subgrid Binding Not Working

1 Answer 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Cynthia
Top achievements
Rank 1
Cynthia asked on 19 Sep 2013, 06:48 PM
@(Html.Kendo().Grid<Zeus.Models.AnswerGroup>(Model.Groups)
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.Id);
        columns.Bound(p => p.QuestionGroupName);
    })
    .Sortable()
    .Pageable()
    .ClientDetailTemplateId("detailTemplate")
    .Events(e => e.DetailInit("onDetailInit"))
    .Events(e => e.DataBound("dataBound"))
)
 
<script id="detailTemplate" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<Zeus.Models.AnswerDetail>()
        .Name("answersGrid_#=Id#")
        .AutoBind(false)
        .DataSource(ds => ds
            .Ajax()
            .ServerOperation(false)).ToClientTemplate()
     )
</script>
 
<script type="text/javascript" language="javascript">
    function dataBound(e) {
        this.expandRow(this.tbody.find("tr.k-master-row").first());
    }
    function onDetailInit(e) {
        var grid = $("#answersGrid_" + e.data.Id).data("kendoGrid");
        grid.dataSource.data(e.Groups.Answers);
    }
</script>
Above is a set of code.  Its not working.  I'm not sure why, maybe there is something obvious.  The grid shows up, but there is no child grid, and the columns are off by one.

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 23 Sep 2013, 11:32 AM
Hello Cynthia,


In the current configuration the parent Grid is configured with a server dataSource, which does not support a client detail template. You should either configure it with an Ajax dataSource or use a server detail template instead.

I wish you a great day!

 

Regards,
Dimiter Madjarov
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
Cynthia
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or