-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
137 lines (126 loc) · 4.48 KB
/
index.html
File metadata and controls
137 lines (126 loc) · 4.48 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Kendo UI Snippet</title>
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.2.621/styles/kendo.common.min.css" />
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.2.621/styles/kendo.rtl.min.css" />
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.2.621/styles/kendo.silver.min.css" />
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.2.621/styles/kendo.mobile.all.min.css" />
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2017.2.621/js/kendo.all.min.js"></script>
<script src="https://da189i1jfloii.cloudfront.net/js/kinvey-phonegap-sdk-3.9.3.min.js"></script>
<script src="kendo.data.kinvey.js"></script>
</head>
<body>
<div id="grid"></div>
<script>
const kinveyAppKey = "kid_HJWVDV4MZ";
const kinveyAppSecret = "42d97e67e01b41f585de1bc5f115a07d";
const email = "1111";
const password = "1111";
Kinvey.init({
appKey: kinveyAppKey,
appSecret: kinveyAppSecret
});
var collectionName = "booksdemo";
var dataStore = Kinvey.DataStore.collection(collectionName, Kinvey.DataStoreType.Network);
var activeUser = Kinvey.User.getActiveUser();
if (activeUser !== null) {
activeUser.me().then(function (activeUser) {
successHandler(activeUser);
}, function (err) {
if (err.name = "InvalidCredentials") {
// we have an active user but its crerdentials are invalid or expired and we need to remove the active user
Kinvey.User.logout()
.then(function () {
// ...
}).catch(function (error) {
// ...
});
}
//
init();
});
} else {
alert("No active user, signing in");
Kinvey.User.login({
username: email,
password: password
})
.then(function (user) {
successHandler(user);
}, function (err) {
alert(JSON.stringify(err));
init();
})
.catch(function (error) {
// ...
init();
});
}
var dataSourceOptions = {
type: "kinvey",
transport: {
// typeName: collectionName
dataStore: dataStore
},
schema: {
model: {
id: "_id"
}
},
error: function (err) {
alert(JSON.stringify(err));
},
serverPaging: true,
pageSize: 5,
serverFiltering: true,
filter: {
field: "author", operator: "neq", value: "someauthor"
},
// serverSorting: true,
sort: {
field: "title",
dir: "asc"
}
};
var dataSource = new kendo.data.DataSource(dataSourceOptions);
function init() {
alert("You should init the app again");
}
function successHandler() {
$("#grid").kendoGrid({
toolbar: ["create"],
dataSource: dataSource,
editable: "inline",
sortable: true,
filterable: true,
pageable: true,
columns: [{
field: "title",
title: "Title"
}, {
field: "author",
title: "Author",
width: "120px"
}, {
field: "isbn",
title: "ISBN",
width: "120px"
}, {
field: "review",
title: "Review notes",
width: "220px"
},
{
command: ["edit", "destroy"],
title: " ",
width: "250px"
}
]
});
}
</script>
</body>
</html>