-
Notifications
You must be signed in to change notification settings - Fork 0
/
ezList.html
172 lines (162 loc) · 6.06 KB
/
ezList.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ezList</title>
<link href='http://fonts.googleapis.com/css?family=Roboto:100,300,700,300italic&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<link rel="stylesheet" href="styles.css">
<link type="text/css" rel="stylesheet" href="sh_styles.css">
</head>
<body onload="sh_highlightDocument();">
<div class="container">
<div class="row header-row">
<div class="col-lg-4 col-lg-offset-4 header_row__picture-container">
<img class="header-row__picture" src="https://lh3.googleusercontent.com/-8irm2nJoeFM/U7hYkk5CLTI/AAAAAAAAG88/YzwVbl1Qxfg/w716-h715-no/IMG_0145.JPG"/>
</div>
</div>
<div class="row content-post">
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 col-lg-offset-3 col-md-offset-3">
<div class="content-post__header">
<h2>ezList</h2>
</div>
<div class="content-post__bread-text">
<strong>ezList</strong> is a javascript library meant for sites with large tables (both a lot of rows and columns). Check out the <b><a href="http://johanrisch.github.io/ezList/index2.html">simple configuration demo</a></b> and the <b><a href="http://johanrisch.github.io/ezList/">advanced configuration demo</a></b>or you can get the source directly from <b><a href="http://github.com/johanrisch/ezList">Github</a></b>
<br/><b>Simpel configuration demo javascript:</b>
<pre class="sh_javascript">
var ezList = new ez.list({
controlDiv: "control",
paginator: {
pageSize: 20,
paginatorContainer: "ezPager"
}
});
</pre>
The paginator object can be removed from the arguments, the only required argument is either "controlDiv", the id of the container to hold all of the toggle, set and filter elements. In the simple demo the table has not been marked with any datafields, they are generated by ezList. It is possible to markup the table with data to inform ezList on how to behave. This can be seen in the <b><a href="http://johanrisch.github.io/ezList/">advanced configuration demo</a>.</b>
<pre class="sh_javascript">
var list = new ez.list({
toggleContainerDiv: "control",
setContainerDiv: "setControl",
filterContainerDiv: "filterContainer",
initial: 0,
sets: [{
name: "Contact and Address",
show: "name,phone,adr,city,country,email",
sortCols: "city,name",
order: "asc",
id: "set1",
actived: function(self) {},
}, {
name: "Salary and age",
show: "name,adr,city,age,salary",
id: "set2",
sortCols: "data6",
order: "desc",
sort: function(a, b) {
var mult = -1;
if (a.data['salary'] === b.data['salary']) {
if (a.data['age'] === b.data['age']) {
return mult * (a.index - b.index);
} else if (a.data['age'] < b.data['age']) {
return mult * -1;
}
return mult * 1;
} else if (a.data['salary'] < b.data['salary']) {
return mult * -1;
}
return mult * 1;
},
actived: function(self) {},
}, {
name: "Bank",
show: "name,card,bank,deposit",
sortCols: "card",
order: "asc",
id: "set3",
activated: function(self) {},
}, {
name: "Employer",
show: "name,employer,iq,6",
id: "set4",
actived: function(self) {},
}],
filters: [{
id: "filter1",
type: "preset",
name: "Salary above 500",
filter: function(item) {
var salary = item.data['salary'].substring(1);
return parseInt(salary) > 500;
}
}, {
id: "filter2",
type: "text",
name: "Search all",
extra: {
column: "all"
}
}, {
id: "filter3",
type: "text",
name: "Search on name",
extra: {
column: "name"
}
}, {
id: "filter4",
type: "text",
name: "Search on phone",
extra: {
column: "phone"
}
}, {
id: "filter5",
type: "text",
name: "{minAge}-{maxAge}",
filter: function(item, value) {
var range = value.split("-");
if (range.length == 2 && range[1].length > 0 && !isNaN(parseInt(range[0], 10)) && !isNaN(parseInt(range[1], 10)) && parseInt(range[0], 10) < parseInt(range[1], 10)) {
var age = parseInt(item.data["age"]);
var minAge = parseInt(range[0]);
var maxAge = parseInt(range[1]);
var ret = (minAge < age && age < maxAge) ? true : false;;
return ret;
} else {
return true;
}
}
}, {
id: "filter6",
type: "text",
name: "{column}_{regexp}",
filter: function(item, value) {
var range = value.split("_");
if (range.length == 2 && range[0].length > 0 && range[1].length > 0 && range[0] in item.data) {
return item.data[range[0]].match(range[1]);
} else {
return true;
}
}
}
],
paginator: {
pageSize: 20,
paginatorContainer: "ezPager"
}
});
</pre>
As you can see there are three types of controls. Toggle buttons (generated by ezList), set buttons and filter fields (defined by you). There really is no limit to what you can do in these filters. Be sure to take a look at the API documentation on gihub to see the full potential.
</div>
</div>
</div>
</div>
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script type="text/javascript" src="sh_javascript.js"></script>
<script type="text/javascript" src="sh_main.min.js"></script>
</body>
</html>