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

ClientTemplate loaded from collection in parent row -> prevent request

1 Answer 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel Grünberger
Top achievements
Rank 1
Daniel Grünberger asked on 06 Feb 2014, 02:34 PM
Hi,

I've posted a question to this topic a year ago and the solution went fine. Today I updated to the newest version of Kendo UI and now I have problems with the code. Looks like the update broke things for me.

The original question was, how to bind data in a clientdata from the parent row. The solution worked by using the DetailInit Method of the Parent Grid to set the data in the datasource of the Childgrid.
http://www.telerik.com/forums/grid-bind-a-clientdetailtemplate-to-a-collection-in-parent-row

My Parent Grid looks like this:
‚Äč
01.@(Html.Kendo().Grid<Models.AgentCommissionDetail>()
02..Name("commissionGrid")
03.        .Columns(
04.            col =>
05.            {
06.                    // cols..
07.            })
08.            .ClientDetailTemplateId("detailTemplate")
09.        .DataSource(dataSource => dataSource
10.       .Ajax()
11.       .ServerOperation(false)
12.    )
13.    .Events(events => events.DetailInit("initDetail"))
14.    .BindTo(Model.GroupedDetails)


Child Template:
01.@(Html.Kendo().Grid<Models.AgentCommissionDetail>()
02.        .Name("details_#=CustomerNr#")
03.        .Columns(col =>
04.        {
05.        // cols
06.        })
07.        .DataSource(dataSource => dataSource
08.            .Ajax()
09.            .ServerOperation(false)
10.           .Sort(p => { p.Add(x => x.ArticleGroup); p.Add(x => x.DiscountGroup); p.Add(x => x.ProductGroup); p.Add(x => x.Revenue).Descending(); })
11.        )
12.        .Pageable()
13.        .Sortable()
14.        .ToClientTemplate()
15.)

And finally the DetailInit to wire it together:
1.function initDetail(e) {
2.    var grid = $("#details_" + e.data.CustomerNr).data("kendoGrid");
3.    grid.dataSource.data(e.data.Details);
4.}

As I said, everything worked fine in the last years version. 

Following steps happen:
 - I expand a row
 - My data is shown as usual
 - But now, an post server request is made to my controller action. That's pretty strange, because I didn't specify any read methods in my datasource.
 - Since no data is returned from the controller, the grid will be empty as soon as the request is finished.

If I comment out the DataSource specification of the Childgrid, no request is made. But then my data is not sortedand Server Paging is enabled. Due to this, I tried to create a new datasource in the initDetail JS-Function, which has the specified sort-definition and turned off server paging. But I'm unable to set the Grid's datasource (already searched in the forums).

Was there a breaking change?

Thanks for any advices.

Greets


1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 10 Feb 2014, 12:36 PM
Hello David,

We are not aware of such breaking change. I updated a similar project that I had and it seems to be working properly. Check the attached archive. In order to investigate further please replicate the problem within a demo project.

Kind Regards,
Petur Subev
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
Daniel Grünberger
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or