forked from rstropek/Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataSourceSample.html
More file actions
76 lines (72 loc) · 2.57 KB
/
DataSourceSample.html
File metadata and controls
76 lines (72 loc) · 2.57 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>DataSource Demo</title>
<!-- Get style sheets from kendo's CDN
In this example we use the Twitter Bootstrap theme. -->
<!-- CDN sources
<link href="http://cdn.kendostatic.com/2014.1.528/styles/kendo.common-bootstrap.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2014.1.528/styles/kendo.bootstrap.min.css" rel="stylesheet" />
-->
<!-- Local sources -->
<link href="Content/KendoUICore/kendo.common-bootstrap.min.css" rel="stylesheet" />
<link href="Content/KendoUICore/kendo.bootstrap.min.css" rel="stylesheet" />
<link href="Samples.css" rel="stylesheet" />
<!-- Get scripts from kendo's CDN
Note that we get JQuery from kendo's CDN, too, to always get a compatible version. -->
<!-- CDN sources
<script src="http://cdn.kendostatic.com/2014.1.528/js/jquery.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.1.528/js/kendo.ui.core.min.js"></script>
-->
<!-- Local sources -->
<script src="Scripts/KendoUICore/jquery.min.js"></script>
<script src="Scripts/KendoUICore/kendo.ui.core.min.js"></script>
</head>
<body>
<input id="localAutoComplete" />
<input id="remoteComboBox" />
<script>
$(document).ready(function () {
// Setup AutoComplete text box bound to local data
var popularFrameworks = [
{ name: "jQuery", source: "http://jquery.com/" },
{ name: "Kendo UI", source: "http://www.telerik.com/kendo-ui" },
{ name: "AngularJS", source: "http://angularjs.org" }
];
var localDataSource = new kendo.data.DataSource({ data: popularFrameworks });
$("#localAutoComplete").kendoAutoComplete({
dataTextField: "name",
dataSource: localDataSource
});
// Setup ComboBox bound to a remote data source via OData
var odataDataSource = new kendo.data.DataSource({
type: "odata",
transport: {
// We use a public read-only OData feed here
read: "http://services.odata.org/Northwind/Northwind.svc/Customers",
dataType: "json"
},
schema: {
data: function (data) {
// Method used to get data from OData result
return data.value;
},
total: function (data) {
// Method used to get total item cound from OData Result
return data['odata.count'];
}
},
// Request sorted result from server
serverSorting: true,
sort: { field: "CompanyName", dir: "desc" }
});
$("#remoteComboBox").kendoComboBox({
dataTextField: "CompanyName",
dataValueField: "CustomerID",
dataSource: odataDataSource
});
odataDataSource.read();
});
</script>
</body>
</html>