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

[Solved] Kendo Grid Popup - binding with Treeview

2 Answers 236 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gert
Top achievements
Rank 1
Gert asked on 23 Jan 2015, 04:04 PM

Hello,

We have a Kendo Grid UI that is databound with a remote JSON.
We want to use the build-in Popup window to add and edit a row.
Now there is one value that needs to be bound to a treeview.
The treenode with the ID of the databound Item should be preselected.
The new value of the selected node should be submitted to the webservice.
Neither is happening.

The TreeView is correctly shown. But is not selecting the right node.



Here my code :
/*
1 PART of the Grid
*/

editable: {
                    mode: "popup",
template: kendo.template($("#popup-editor-werkaanvraag").html())
                    },
  edit: function(e){
  var inlineDefault = new kendo.data.HierarchicalDataSource({
                                data: [
                                    {text: "KK",id:0, items: [
                                            {text: "Hoofdgebouw",id:150},
                                            {text: "Pav 1",id:151},
                                            {text: "Pav 2",id:152}
                                        ]},
                                    {text: "SRF",id:1, items: [
                                            {text: "Bed Linen",id:154},
                                            {text: "Curtains & Blinds",id:155},
                                            {text: "180",id:180}
                                        ]}
                                ]
                            });
         }
  var treeview = e.container.find(".nested-treeview").kendoTreeView({
                                dataSource: inlineDefault
                            });

     } 


/*
2 PART of the Template
*/

  <script id="popup-editor-werkaanvraag" type="text/x-kendo-template"> 
<div style="width:800px" date-role="treeview" class="nested-treeview"  data-bind="value:locatie_id" ></div>
  </script>

2 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 27 Jan 2015, 11:18 AM
Hello Gert,

Adding a "selected" property to the desired node is one way to achieve the desired behavior. For example: 
var inlineDefault = new kendo.data.HierarchicalDataSource({
    data: [
        {selected: true, text: "KK",id:0, items: [
                {text: "Hoofdgebouw",id:150},
                {text: "Pav 1",id:151},
                {text: "Pav 2",id:152}
            ]},
        {text: "SRF",id:1, items: [
                {text: "Bed Linen",id:154},
                {text: "Curtains & Blinds",id:155},
                {text: "180",id:180}
            ]}
    ]
});

Alternatively, you can manually select the node after the TreeView has been initialized.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Gert
Top achievements
Rank 1
answered on 30 Jan 2015, 09:58 AM
ok, I'll try this out. Thx for the fast reply.
Tags
Grid
Asked by
Gert
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Gert
Top achievements
Rank 1
Share this question
or