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

Datasource Bind to Form / Input

1 Answer 476 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Christopher
Top achievements
Rank 1
Christopher asked on 20 Aug 2015, 11:28 AM

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>

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 24 Aug 2015, 08:23 AM

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!
 
Tags
Data Source
Asked by
Christopher
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or