Reputation: 8626
According to the kendo documentation data binding is done by adding a data-bind attribute on an element in a template and the kendo framework will figure out the details. I put together a simple js fiddle to show the problem I'm having as this does not appear to be doing what I would expect ...
https://stackoverflow.com/questions/ask
<script id="string" type="text/x-kendo-template">
<label>String</label>
<input type="text" data-bind="value: data" />
</script>
<script id="number" type="text/x-kendo-template">
<label>Number</label>
<input type="number" data-role="numerictextbox" data-bind="value: data" />
</script>
<script id="date" type="text/x-kendo-template">
<label>Date</label>
<input type="date" data-role="datepicker" data-bind="value: data" />
</script>
<script id="editor" type="text/x-kendo-template">
<h2>Object Id: #: id #</h2>
<ul class="fields">
<li data-template="string" data-bind="source: name"></li>
<li data-template="number" data-bind="source: age"></li>
<li data-template="date" data-bind="source: dob"></li>
</ul>
</script>
<script>
$(function () {
var model = new kendo.observable({
id: 1, age: 23, name: 'Smith', dob: '"1980-01-01T00:00:00Z"'
});
$(function () {
kendo.bind($("#component"), model);
});
});
</script>
<div id="component"
data-bind="source: this"
data-template="editor" />
Why is this not binding the values in the fields correctly, as i just get empty text boxes implying the templating is working but the binding isn't?
Upvotes: 1
Views: 2041
Reputation: 5708
This is works for me in template
<script type="text/x-kendo-template" id="template">
<div class="k-edit-label"><label for="Name">Name</label></div>
<input type="text"
class="k-input k-textbox"
name="Name"
data-bind="value: Name"
style="margin-left:10px">
<br>
<br
<div class="k-edit-label"><label for="StudentId">Student Id</label></div>
<input type="text"
class="k-input k-textbox"
name="StudentId"
data-bind="value: StudentId"
style="margin-left:10px">
</script>
Upvotes: 1
Reputation: 8626
After some extended email trails the basic answer was "kendo doesn't work like this". It appears to be based on conventions / peculiar behaviour that varies depending on the binding situation and I am seemingly using the wrong approach with real definition of why as the tutorials / demos appear to contradict themselves.
Be warned people. kendo is not going to be polite to you without a fight!
Upvotes: 0