-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
290 lines (227 loc) · 10.8 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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<!DOCTYPE html>
<html>
<head>
<title>ArrestGrid</title>
<meta charset="utf-8">
<link href="vendor/kendo/examples-offline.css" rel="stylesheet">
<link href="vendor/qtip2/jquery.qtip.min.css" rel="stylesheet">
<link href="vendor/kendo/kendo.rtl.min.css" rel="stylesheet">
<link rel="stylesheet" href="vendor/kendo/kendo.common-bootstrap.min.css">
<link rel="stylesheet" href="vendor/kendo/kendo.bootstrap.min.css">
<script src="vendor/jquery-2.0.3.min.js"></script>
<script type='text/javascript' src="vendor/jquery.rest.min.js"></script>
<script src="vendor/kendo/kendo.web.min.js"></script>
<script src="vendor/qtip2/jquery.qtip.min.js"></script>
<script>
</script>
<style type="text/css">
td {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
</style>
</head>
<body>
<div id="example" class="k-content">
<center>
<div class="input-append search">
<input type="text" size="55" id="url" class="input-max span7" onchange="refresh()" placeholder="DB URL" value="http://dataverse.ro/db2/index.php/table1/"> <a href="#" onclick="refresh()" class="k-pager-refresh k-link" title="Refresh"><span class="k-icon k-i-refresh">Refresh</span></a>
</div>
</center>
<div id="grid"></div>
<script id="template_csv" type="text/x-kendo-template">
<a class="k-button" href="\#" onclick="return toolbar_click()">get CSV</a>
</script>
<script id="template_edit" type="text/x-kendo-template">
<a class="k-button k-edit" href="\#" onclick="return edit_rec()"><span class="k-icon k-edit"></span></a>
</script>
<script id="template_delete" type="text/x-kendo-template">
<a class="k-button k-delete" href="\#" onclick="return del_rec()"><span class="k-icon k-delete"></span></a>
</script>
<script>
function toolbar_click() {
console.log("Toolbar command is clicked!");
return false;
}
function edit_rec(){
grid = $("#grid").data("kendoGrid");
grid.editRow(grid.select());
}
function del_rec(){
grid = $("#grid").data("kendoGrid");
grid.removeRow(grid.select());
}
function refresh(){
grid = $("#grid").data("kendoGrid");
prep_ds()
dataSource.read()
grid.refresh()
}
// http://localhost:5984/example/ http://localhost/subject.ro/db/tree_cache2/ "
var dataSource;
var grid;
function prep_ds(){
dataSource = new kendo.data.DataSource({
type: "jsonp",
columns: [{
command: [
{ className: "btn-edit", name: "edit", text: "" },
{ className: "btn-destroy", name: "destroy", text: "" }
]
}],
transport: {
read: {
url: $("#url").val(),
type: "GET",
dataType: "jsonp",
},
parameterMap: function(options,type) {
console.log(type)
switch(type){
case "read":
$.extend(options,{
//q: "javascript",
offset: (options.page-1)*options.pageSize,
limit: options.pageSize
}) /* */
return options;
case "destroy":
return options;
default:
return options ;
}
},
create: {
url: function (db) {
return $("#url").val();
},
type: "POST",
contentType: "application/x-www-form-urlencoded",
dataType: "jsonp"
},
update: {
url: function (db) {
console.log(db);
return $("#url").val() + db.id;;
},
type: "PUT",
contentType: "application/x-www-form-urlencoded",
success: function (result) {
console.log(result);
},
//dataType: "jsonp"
},
destroy: {
url: function (db) {
return $("#url").val() + db.id;
},
type: "DELETE",
//dataType: "json"
},
},
schema: {
data: function(data) {
return data
},
model: { id: "id" }
},
pageSize: 5,
serverPaging: true,
serverFiltering: true,
serverSorting: true
});
}
$(document).ready(function() {
//sessionStorage.setItem("kendoSkin", "bootstrap");
prep_ds();
grid = $("#grid").kendoGrid({
//autoBind: false,
//,
/*
columns: [ {
command: [
{ className: "btn-edit", name: "edit", text: "" },
{ className: "btn-destroy", name: "destroy", text: "" }
]
}
],
*/
dataSource: dataSource,
/* */
height: 550,
mobile: true,
sortable: true,
filterable: true,
columnMenu: true,
pageable: {
pageSize: 5,
pageSizes: [5, 10, 50, 100, 500, 1000],
input: true,
//pageSizes: true,
refresh: true,
messages: {
itemsPerPage: "data items per page"
}
},
/* */
resizable: true,
scrollable:true,
selectable: true,
toolbar: [
{ name: "create" , text: ""},
{ name: "save", text: "" },
{ template: kendo.template($("#template_edit").html()) },
{ template: kendo.template($("#template_delete").html()) },
{ template: kendo.template($("#template_csv").html()) }
] ,
editable: {
mode: "inline", // "popup", "inline",
confirmation: false
},
dataBinding2: function(e) {
console.log("dataBinding");
//console.log(this)
/*
this.columns.push( {
command: [
{ className: "btn-edit", name: "edit", text: "" },
{ className: "btn-destroy", name: "destroy", text: "" }
]
});
*/
},
dataBound: function(e) {
console.log("dataBound");
//var grid = $("#grid").data("kendoGrid");
//grid.resize(true);
$('td').each(function() { // Grab all "<a>" elements, and for each...
$(this).qtip({ //
content: {
text: $(this).html() // WILL work, because .each() sets "this" to refer to each element
},
position: {
my: 'top right', // Position my top left...
//at: 'bottom right', // at the bottom right of...
target: "mouse" //$('td') // my target
}
});
});
//$("td").bind("mouseover",function(e){})
/*
this.columns.push( {
command: [
{ className: "btn-edit", name: "edit", text: "" },
{ className: "btn-destroy", name: "destroy", text: "" }
]
});
*/
//grid.setDataSource(dataSource);
}
});
//alert("fe")
});
</script>
</div>
</body>
</html>