Grid editable.template

3 posts, 1 answers
  1. Rodion Nikolaev
    Rodion Nikolaev avatar
    4 posts
    Member since:
    May 2014

    Posted 15 Oct 2014 Link to this post

    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. Answer
    Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 17 Oct 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Rodion Nikolaev
    Rodion Nikolaev avatar
    4 posts
    Member since:
    May 2014

    Posted 17 Oct 2014 Link to this post

    Thank you. All work fine.  I am happy.
Back to Top