-
Notifications
You must be signed in to change notification settings - Fork 0
/
grid.html
112 lines (100 loc) · 3.84 KB
/
grid.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled</title>
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2015.2.805/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2015.2.805/styles/kendo.default.min.css">
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2015.2.805/js/angular.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2015.2.805/js/kendo.web.min.js"></script>
<script src="http://oemobiledemo.progress.com/jsdo/progress.all.min.js"></script>
</head>
<body ng-app="app" ng-controller="Main">
<div kendo-grid k-options="gridOptions" k-on-change="selectCustomer(dataItem)"></div>
<form ng-show="selection" ng-submit="save()">
<fieldset>
<legend>Details for {{selection.CustNum}}</legend>
<div>
<label for="Name">Name: </label><input ng-model="selection.Name" id="Name">
</div>
<div>
<label for="Sate">State: </label><input ng-model="selection.State" id="Sate">
</div>
<div>
<label for="Country">Country: </label><input ng-model="selection.Country" id="Country">
</div>
<div>
<button type="submit">Save</button>
</div>
</fieldset>
</form>
<script>
var serviceURI = 'http://oemobiledemo.progress.com/CustomerService';
var catalogURI = 'http://oemobiledemo.progress.com/CustomerService/static/mobile/CustomerService.json';
var resourceName = 'Customer';
var session = new progress.data.Session();
session.login(serviceURI, "", "");
session.addCatalog(catalogURI);
var app = angular.module("app", ["kendo.directives"]);
app.controller("Main", ["$scope", MainController]);
function wrap(data) {
var observable = {};
Object.keys(data).forEach(function(property) {
Object.defineProperty(observable, property, {
get: function() {
return data[property];
},
set: function(value) {
data[property] = value;
data.dirty = true;
}
});
});
return observable;
}
function MainController($scope) {
$scope.customerDS = new kendo.data.DataSource({
type: "jsdo",
transport: {
jsdo: resourceName
},
error: function (e) {
console.log('Error: ', e);
},
pageSize: 10
});
$scope.selectCustomer = function(customer) {
$scope.selection = wrap(customer);
};
$scope.save = function() {
$scope.customerDS.sync();
};
$scope.gridOptions = {
dataSource: $scope.customerDS,
selectable: "row",
height: 350,
pageable: {
refresh: true,
pageSizes: true,
pageSize: 10,
buttonCount: 5
},
columns: [
{ field: "CustNum", title: "Cust Num", type: "number", width: 100 },
{ field: "Name" },
{ field: "State" },
{ field: "Country" },
{ command: ["destroy"], title: " ", width: "250px" }
],
dataBound: function() {
if ($scope.selection) {
var dataItem = this.dataSource.get($scope.selection._id);
this.select(this.tbody.find("[data-uid='" + dataItem.uid + "']"));
}
}
};
}
</script>
</body>
</html>