forked from kendo-labs/kendo-backbone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
60 lines (52 loc) · 2.15 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html>
<head>
<title>Kendo UI and Backbone</title>
<link href="http://cdn.kendostatic.com/2012.1.322/styles/kendo.common.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2012.1.322/styles/kendo.default.min.css" rel="stylesheet" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://cdn.kendostatic.com/2012.1.322/js/kendo.web.min.js"></script>
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
<script src="http://backbonejs.org/backbone-min.js"></script>
<script src="kendo.backbone.js"></script>
</head>
<body>
<h3>Grid</h3>
<div id="grid">
</div>
<h3>Backbone collection</h3>
<pre id="log">
</pre>
<script>
var Product = Backbone.Model.extend({
});
var ProductCollection = Backbone.Collection.extend({
model: Product
});
var products = new ProductCollection(
[
{ ProductID: 1, Name: "Food"}, { ProductID: 2, Name: "Coffee"}
]);
var ProductWrapper = kendo.backboneModel(Product, {
ProductID: { type: "number" },
Name: { type: "string" }
});
var ProductCollectionWrapper = kendo.backboneCollection(ProductWrapper);
products.on("change remove", function() {
$("#log").text(kendo.stringify(products.toJSON()));
});
$("#log").text(kendo.stringify(products.toJSON()));
$("#grid").kendoGrid({
editable: true,
toolbar: ["create"],
columns: ["ProductID", "Name", { command: "destroy" }],
dataSource: {
schema: {
model: ProductWrapper
},
data: new ProductCollectionWrapper(products)
}
});
</script>
</body>
</html>