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

How to bind value in ng-model in hierarchical children grid.

3 Answers 448 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dhara
Top achievements
Rank 1
Veteran
Dhara asked on 06 Nov 2017, 12:34 PM

I can not able to bind value in detailInit function in coloumn template: "<input ng-model='data.itemId' />", title: "item Id". data.itemId not working in children grid

 vm.gridOptions1 = {
            dataSource: {
                batch: true,
                data: [{
                    id: 1,
                    name: "Abra",
                    items: [{
                        itemId: 10,
                        sku: "ABC123"
                    }, {
                        itemId: 11,
                        sku: "DEF567"
                    }]
                }, {
                    id: 2,
                    name: "Kadabra",
                    items: [{
                        itemId: 20,
                        sku: "ABC678"
                    }, {
                        itemId: 21,
                        sku: "GHI567"
                    }]
                }]
            },
            detailInit: vm.detailInit,
            editable:true,                      
            navigatable:true,     
            columns: [{
                field: "id",
            }, {
                // field: "name",
                template: "<input type='text' ng-model='dataItem.name' />", title: "name"
            }, ]
        }

        function detailInit(e) {
            var dataTest = e.data.items;
            var grid = this;
            $("<div/>").appendTo(e.detailCell).kendoGrid({
                dataSource: dataTest,
                editable: true,
                columns: [{
                    // field: "itemId"
                     template: "<input ng-model='data.itemId' />", title: "item Id"
                }, {
                    field: "sku"
                      // template: "<input ng-model='dataItem.sku' />", title: "sku"
                } ],
                save: function() {
                    grid.one("dataBinding", function(e) {
                        e.preventDefault();
                    });
                }
            });
        }

 

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 08 Nov 2017, 07:31 AM
Hello, Dhara,

I made an example with hierarchical Grid, used the provided template on the parent and the child Grids and both are bound:

http://dojo.telerik.com/eFOqIl

Please advise if I missed an important detail.
 
Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Dhara
Top achievements
Rank 1
Veteran
answered on 08 Nov 2017, 10:12 AM

Hi Stefan

I am using single transport read method and I added my hierarchical table information in items key check my json. I can not able to access sub child table  items value in template in ng-model. I am using detailInit function for hierarchical table. Can you explain me how i will create with single transport read method with in single grid. In your example you are using two different gird and two different transport read method.  

dataSource: {

                batch: true,
                data: [{
                    id: 1,
                    name: "Abra",
                    items: [{
                        itemId: 10,
                        sku: "ABC123"
                    }, {
                        itemId: 11,
                        sku: "DEF567"
                    }]
                }, {
                    id: 2,
                    name: "Kadabra",
                    items: [{
                        itemId: 20,
                        sku: "ABC678"
                    }, {
                        itemId: 21,
                        sku: "GHI567"
                    }]
                }]
            }

0
Stefan
Telerik team
answered on 10 Nov 2017, 06:41 AM
Hello, Dhara,

Thank you for providing the data structure.

I made an example using the provided data and it is bound as expected:

http://dojo.telerik.com/eFOqIl/2

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Dhara
Top achievements
Rank 1
Veteran
Answers by
Stefan
Telerik team
Dhara
Top achievements
Rank 1
Veteran
Share this question
or