-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
74 lines (71 loc) · 2.01 KB
/
index.js
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
const SERVICE_URI =
'https://services.odata.org/V4/Northwind/Northwind.svc/Orders/';
var datas = new ej.data.DataManager({
adaptor: new ej.data.CustomDataAdaptor({
getData: function (option) {
var query = JSON.parse(option.data);
var take = query.take;
var skip = query.skip;
var url = SERVICE_URI + '?$count=true';
if (skip) {
url = url + '&$skip=' + skip;
}
if (take) {
url = url + '&$top=' + take;
}
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4) {
request = ej.base.extend({}, option, { httpRequest: xhttp });
if (
(xhttp.status >= 200 && xhttp.status <= 299) ||
xhttp.status === 304
) {
var datatemp = JSON.parse(xhttp.responseText);
var gridData = {
result: datatemp.value,
count: datatemp['@odata.count'],
};
console.log(gridData);
option.onSuccess(gridData, request);
} else {
option.onFailure(request);
}
}
};
xhttp.open('GET', url, true);
xhttp.send();
},
}),
});
var grid = new ej.grids.Grid({
dataSource: datas,
enableInfiniteScrolling: true,
height: 300,
columns: [
{
field: 'OrderID',
headerText: 'Order ID',
width: 120,
textAlign: 'Right',
},
{ field: 'CustomerID', headerText: 'Customer Name', width: 150 },
{
field: 'OrderDate',
headerText: 'Order Date',
width: 130,
format: 'yMd',
textAlign: 'Right',
},
{ field: 'Freight', width: 120, format: 'C2', textAlign: 'Right' },
{
field: 'ShippedDate',
headerText: 'Shipped Date',
width: 140,
format: 'yMd',
textAlign: 'Right',
},
{ field: 'ShipCountry', headerText: 'Ship Country', width: 150 },
],
});
grid.appendTo('#Grid');