forked from sharafat/SpreadJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflexigrid.html
executable file
·155 lines (149 loc) · 7.18 KB
/
flexigrid.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Spread JS</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/flexigrid.pack.css" />
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="js/flexigrid.pack.js"></script>
<script type="text/javascript" src="js/jquery.editinplace-v2.2.1.js"></script>
</head>
<body>
<table class="flexme4" style="display: none"></table>
<script type="text/javascript">
$(".flexme4").flexigrid({
url: 'data.json',
dataType : 'json',
colModel : [ {
display : 'EmployeeID',
name : 'employeeID',
width : 90,
sortable : true,
align : 'center'
}, {
display : 'Name',
name : 'name',
width : 120,
sortable : true,
align : 'left'
}, {
display : 'Primary Language',
name : 'primary_language',
width : 120,
sortable : true,
align : 'left'
}, {
display : 'Favorite Color',
name : 'favorite_color',
width : 80,
sortable : true,
align : 'left',
hide : true
}, {
display : 'Favorite Animal',
name : 'favorite_pet',
width : 80,
sortable : true,
align : 'right'
} ],
buttons : [ {
name : 'Add',
bclass : 'add',
onpress : Example4
}
,
{
name : 'Edit',
bclass : 'edit',
onpress : Example4
}
,
{
name : 'Delete',
bclass : 'delete',
onpress : Example4
}
,
{
separator : true
}
],
searchitems : [ {
display : 'EmployeeID',
name : 'employeeID'
}, {
display : 'Name',
name : 'name',
isdefault : true
} ],
sortname : "iso",
sortorder : "asc",
usepager : true,
title : 'Employees',
useRp : true,
rp : 15,
showTableToggleBtn : true,
width : 750,
height : 200
});
function Example4(com, grid) {
if (com == 'Delete') {
var conf = confirm('Delete ' + $('.trSelected', grid).length + ' items?')
if(conf){
$.each($('.trSelected', grid),
function(key, value){
$.get('example4.php', { Delete: value.firstChild.innerText}
, function(){
// when ajax returns (callback), update the grid to refresh the data
$(".flexme4").flexReload();
});
});
}
}
else if (com == 'Edit') {
var conf = confirm('Edit ' + $('.trSelected', grid).length + ' items?')
if(conf){
$.each($('.trSelected', grid),
function(key, value){
// collect the data
var OrgEmpID = value.children[0].innerText; // in case we're changing the key
var EmpID = prompt("Please enter the New Employee ID",value.children[0].innerText);
var Name = prompt("Please enter the Employee Name",value.children[1].innerText);
var PrimaryLanguage = prompt("Please enter the Employee's Primary Language",value.children[2].innerText);
var FavoriteColor = prompt("Please enter the Employee's Favorite Color",value.children[3].innerText);
var FavoriteAnimal = prompt("Please enter the Employee's Favorite Animal",value.children[4].innerText);
// call the ajax to save the data to the session
$.get('example4.php',
{ Edit: true
, OrgEmpID: OrgEmpID
, EmpID: EmpID
, Name: Name
, PrimaryLanguage: PrimaryLanguage
, FavoriteColor: FavoriteColor
, FavoritePet: FavoriteAnimal }
, function(){
// when ajax returns (callback), update the grid to refresh the data
$(".flexme4").flexReload();
});
});
}
}
else if (com == 'Add') {
// collect the data
var EmpID = prompt("Please enter the Employee ID","5");
var Name = prompt("Please enter the Employee Name","Mark");
var PrimaryLanguage = prompt("Please enter the Employee's Primary Language","php");
var FavoriteColor = prompt("Please enter the Employee's Favorite Color","Tan");
var FavoriteAnimal = prompt("Please enter the Employee's Favorite Animal","Dog");
// call the ajax to save the data to the session
$.get('example4.php', { Add: true, EmpID: EmpID, Name: Name, PrimaryLanguage: PrimaryLanguage, FavoriteColor: FavoriteColor, FavoritePet: FavoriteAnimal }
, function(){
// when ajax returns (callback), update the grid to refresh the data
$(".flexme4").flexReload();
});
}
}
</script>
</body>
</html>