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

MVVM Kendo grid hierarchy data does not display

1 Answer 117 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AAA
Top achievements
Rank 1
AAA asked on 28 Jul 2015, 01:52 AM

I have an MVVM application using Kendo Grid, and I want to display hierarchy (nested grid). I am not able to display the hierarchy data. How can I get the hierarchy records to display?  

cshtml code:

<div id="custOrderGrid"
        data-role="grid"
        data-resizable="false"
        data-navigatable="true"
        data-editable="true"
        data-pageable="false"
        data-scrollable="true"
        onscroll="true"
        data-detail-template="child-template"
        data-columns="[
                { 'field': 'OrderID', 'title': '<b>Order #', 'width': 65 },
                { 'field': 'LineNo', 'title': '<b>Line Number', 'width': 65 },
                { 'field': 'ItemNo', 'title': '<b>Item Number', 'width': 65 },
                { 'field': 'Desc', 'title': '<b>Description', 'width': 150 }
            ]"
        data-bind="source: orderSearchResults"
        style="height: 55%">
</div>
 
<script id="child-template" type="text/x-kendo-template">
    <div data-role="grid"
         data-bind="source: obj2"
         data-columns="[
    { field: 'name' },
    { field: 'oid' }
    ]"></div>
</script>

 

typescript code

orderSearchResults = new kendo.data.DataSource({
    schema: {
        model: {
            id: "OrderID",
            fields: {
                LineNo: { type: "string" },
                ItemNo: { type: "string" },
                Description: { type: "string" }
            }
        }
    },
            data: [
                {
                    OrderID: "L44ZX4", LineNo: "15", ItemNo: "*X1WCJH", Description: "CDF9X2XSB",
                    obj2: [{
                        name: 'a1',
                        oid: 1
                        },
                        {
                            name: 'b1',
                            oid: 2
                        },
                        {
                            name: 'c1',
                            oid: 3
                        }]
                }
            ]
        });

 

How can I get the hierarchy data to display?

 

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 29 Jul 2015, 03:49 PM
Hello Asim,

The issue occurs because the Grid will not automatically bind the detail template. You should this manually at the detailInit event handler. Please check this example:


Regards,
Alexander Valchev
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
AAA
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or