Datasource Bind to Form / Input

2 posts, 0 answers
  1. Christopher
    Christopher avatar
    9 posts
    Member since:
    Apr 2013

    Posted 20 Aug 2015 Link to this post

    Hey guys,

    perhaps a simple question, but i'm a little bit confused about this... How can i bind a remote datasource to a simple form. I know already which ID i want to use, but i don't know how to get the one specific ID and bind the Field to an input. In this case i open my page "http://myurl/form.php?id=618" and would like to fill out the whole form.

    Thanks,
    Chris

     

    <form id="myForm">
      <ul>
        <li>
          <input type="text" id="myField" class="k-textbox" data-bind="value:myField" />
        </li>
      </ul>
    </form>
     
    <script>
    var dataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url: "http://myURL",
                dataType: "json",
                type: "GET",
                contentType: "application/json"
            }
        },
        schema: {
            model: {
                id: "ID",
                fields: {
                    ID: "ID",
                    myField: "myField",
                }
            }
        }
    });
    </script>

  2. Rosen
    Admin
    Rosen avatar
    3237 posts

    Posted 24 Aug 2015 Link to this post

    Hello Christopher,

    The DataSource is design to work with a collection of objects. Therefore, you will need to pick one of the objects, available in the DataSource and bind the form to it. Similar scenario is demonstrated in this online demo.

    Regards,
    Rosen
    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
Back to Top