For some reason beyond me, my view doesn't get updated when changing the viewmodel. What am I doing wrong here?
It displayes:
Test1 100
Test2 200
When I expect:
Test1 300
Test2 400
Javascript:
var testModel = kendo.data.Model.define({
fields: {
"Name": {
type: "text"
},
"Amount": {
type: "number"
}
}
});
testViewModel = new kendo.observable({
Data: [
new testModel({ "Name": "Test1", "Amount": 100 }),
new testModel({ "Name": "Test2", "Amount": 200 })
]
});
kendo.bind("#test", testViewModel.Data);
var data = testViewModel.Data;
data[0].Amount = 300;
data[1].Amount = 400;
testViewModel.set("Data", data);
HTML:
<div id="test" data-bind="source: Data" data-template="testTemplate"></div>
<script id="testTemplate" type="text/x-kendo-template">
<div>
<span data-bind="text: Name"></span>
<span data-bind="text: Amount"></span>
</div>
</script>
Apparently I needed to set a trigger to update the template, after updating the viewmodel.
Like this: