Ivan Crojach Karačić
Ivan Crojach Karačić

Reputation: 1911

Kendo UI Grid hierarchy

What I have is the following DTO which gets passed from the service

class ServiceDto
{
     public string Name { get; set; }
     public string Complete { get; set; }
     public string Incomplete{ get; set; }
     public List<ServiceDto> Detail{ get; set; }
}

In essence I have a team which has users in it and the data which is returned by the service can look something like this

 Team 1               3          5
     John Doe         1          3
     Mike Low         2          2

 Team 2               3          3
     Bob Smith        1          2
     Alice Smith      2          1

I have implemented the first part of the equastion like this:

 $(document).ready(function () {
    var element = $("#grid").kendoGrid({
        dataSource: {
            type: "json",
            transport: {
                read: "../home/service"
            }                
        }
        detailInit: detailInit,
        dataBound: function () {
            this.expandRow(this.tbody.find("tr.k-master-row").first());
        },
        columns: [
            { field: "Name", title: "Team Name"},
            { field: "Complete"},
            { field: "Incomplete"}
        ]
    });
});

But I am not sure how to pass the details of each result to the detailInit init function which looks like this at the momment:

function detailInit(e) {
    $("<div/>").appendTo(e.detailCell).kendoGrid({
        dataSource: {
            type: "json",
            transport: {
                read: ???
            },
        },            
        columns: [
            { field: "Name", title: "User Name" },
            { field: "Complete", title: "Completed task" },
            { field: "Incomplete", title: "Incomplete tasks" }
        ]
    });
}

What do I need to do to pass the data from the parent?

Upvotes: 4

Views: 3874

Answers (1)

OnaBai
OnaBai

Reputation: 40887

In detailInit function you can get master data in e.data.

BTW: Did you consider using KendoUI Grid Aggregates? See demo here

Upvotes: 3

Related Questions