i am evaluating Kendo and it looks fantastic, we use knockout, and i have noticed that kendo MVVM is almost the exact of knockout, but one thing i like about kockout is that you don't have to use java script block to define for-each templates, you just do it in the markup, so is this possible with kendo ?
thanks in advanced
12 Answers, 1 is accepted
You can use the source binding and a template to do the same. This example shows how.
Greetings,Atanas Korchev
the Telerik team
but this is the exact opposite of what i mentioned
i dont want this
<script id="row-template" type="text/x-kendo-template">
<tr>
<td data-bind="text: name">
</td>
<td>
#: kendo.toString(get("price"), "C") #
</td>
<td data-bind="text: unitsInStock"></td>
</tr>
</script>
i want this
http://knockoutjs.com/documentation/foreach-binding.html
This is not supported by Kendo MVVM. Using the template and the source binding is the way to work with repeating data.
Regards,Atanas Korchev
the Telerik team
jsfiddle
...am I just doing it wrong?
What does not work? What is the expected outcome? Could you elaborate a bit?
Greetings,Atanas Korchev
the Telerik team
So lets remove the nesting from it and just try and show the root campuses array
http://jsfiddle.net/stevescotthome/VeyLC/1/
It knows there should be 3 items, but the one is just blank...should render Hamilton, Waterloo, Niagara...but its just rendering Hamilton, Niagara, <empty>
So the question is that do we need to do a manual for loop inside the template as well...and if so then we'd lose the data-bind syntax wouldn't we?
I guess then that you can just use nested templates and source bindings like this: http://jsfiddle.net/korchev/SgLsB/2/
Kind regards,Atanas Korchev
the Telerik team
http://jsfiddle.net/stevescotthome/5MYEe/
The problem is that a template should have only one root tag when used together with the source binding. Kendo MVVM needs to map one DOM element to one item from the array which is specified as the source binding. In your case you have more than one root element in the template. Wrapping the whole template in a div solves the problem: http://jsfiddle.net/korchev/5MYEe/13/ . We will add this to the documentation of the source binding.
All the best,Atanas Korchev
the Telerik team