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

Grid editable.template

2 Answers 220 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Rodion Nikolaev
Top achievements
Rank 2
Rodion Nikolaev asked on 15 Oct 2014, 09:41 PM
In  Grid documentation in section editable.template  show how bind value to numeric text box :
     <label>Age: <input data-role="numerictextbox" name="age" /></label>

I need bind value to dropdown list. I change code like this:

<script id="popup-editor" type="text/x-kendo-template">
  <h3>Edit Person</h3>
  <p>
    <label>Name:<input name="name" /></label>
  </p>
  <p>
    <label>Age: <input data-role="dropdownlist" data-bind="value: age, source: dataSource" /></label>
  </p>
</script>
<div id="grid"></div>
<script>
$("#grid").kendoGrid({
  columns: [
    { field: "name" },
    { field: "age" },
    { command: "edit" }
  ],
  dataSource: {
    data: [
      { id: 1, name: "Jane Doe", age: 30 },
      { id: 2, name: "John Doe", age: 33 }
    ],
    schema: {
      model: { id: "id" }
    }
  },
  editable: {
    mode: "popup",
    template: kendo.template($("#popup-editor").html())
  }
});
 
  var dataSource = new kendo.data.DataSource({
  data: [ 21,22,23,24  ]
}); 
</script>

But  dataSource do not bound. Whats wrong?


2 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay Rusev
Telerik team
answered on 17 Oct 2014, 07:59 AM
Hello Rodion,

Binding expressions should be as follows:
data-bind="value: age" data-source="dataSource"

This way the as dataSource global variable will be picked as data source. Here is an example: http://dojo.telerik.com/@rusev/aMUQ.

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Rodion Nikolaev
Top achievements
Rank 2
answered on 17 Oct 2014, 08:35 AM
Thank you. All work fine.  I am happy.
Tags
Templates
Asked by
Rodion Nikolaev
Top achievements
Rank 2
Answers by
Nikolay Rusev
Telerik team
Rodion Nikolaev
Top achievements
Rank 2
Share this question
or