Kendo UI MVVM and the Grid: Example 01
Introduction to binding an editable Grid to a ViewModel
HTML
<link rel="stylesheet" href="http://cdn.kendostatic.com/2012.2.710/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2012.2.710/styles/kendo.default.min.css">
<script src="http://cdn.kendostatic.com/2012.2.710/js/kendo.all.min.js"></script>
<div id="people">
<div data-role="grid"
data-bind="source: people"
data-editable="true"
data-toolbar="['edit', 'destroy']"
data-columns='[{"field": "firstName", "title": "First Name"},
{"field": "lastName", "title": "Last Name"}]'>
</div>
</div>
JavaScript
// Define a DataSource
var peopleDataSource = new kendo.data.DataSource({
data: [
{ id: 1, firstName: "John", lastName: "DeVight" },
{ id: 2, firstName: "Wendy", lastName: "Parry" }
]
});
// Create an observable object.
var vm = kendo.observable({
people: peopleDataSource
});
kendo.bind($("#people"), vm);