-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfiltering.php
More file actions
159 lines (146 loc) · 4.57 KB
/
filtering.php
File metadata and controls
159 lines (146 loc) · 4.57 KB
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
<?php
/**
* Created by PhpStorm.
* User: shady
* Date: 3/3/19
* Time: 5:53 AM
*/
include "./functions.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>Filtering a table with vue</title>
<!-- Bootstrap core CSS -->
<link href="./css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="./css/narrow-jumbotron.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js"></script>
</head>
<style>
</style>
<body>
<div class="container" id="app">
<div class="header clearfix">
<nav>
<ul class="nav nav-pills float-right">
<li class="nav-item">
<a class="nav-link active" href="table.php">Filter Table</a>
</li>
</ul>
</nav>
<h3 class="text-muted">Vue Quantity Table</h3>
</div>
<div class="jumbotron">
<h1 class="display-3">Filter a Table</h1>
<p class="lead">Filtering a table with vue.js</p>
<input type="text" v-model="query" placeholder="Search"/>
<button @click="search()" >Search</button>
</div>
<div class="container">
<div class="wizard">
<table class="table">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Email</th>
<th scope="col">User Type</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody>
<tr v-for="row in rows">
<td>{{ row.name }} </td>
<td>{{ row.email }}</td>
<td><span class="badge badge-default">{{ row.type }}</span></td>
<td>{{ row.status }}</td>
</tr>
</tbody>
</table>
<hr>
<br><br>
</div>
</div>
<footer class="footer">
<p>© Company 2017</p>
</footer>
</div> <!-- /container -->
<script>
var myObject = new Vue({
el: '#app',
data : {
query: "",
originalrows :[],
rows : [
{
'id' : 1,
'name' : 'Wynton Franlin',
'email' : 'wf@gmail.com',
'type' : 'Member',
'status' : 'Active',
},
{
'id' : 2,
'name' : 'James Barkel',
'email' : 'jamesbarkely@gmail.com',
'type' : 'Member',
'status' : 'Active',
},
{
'id' : 3,
'name' : 'Tommy Gun',
'email' : 'Tg@gmail.com',
'type' : 'Admin',
'status' : 'InActive',
},
{
'id' : 4,
'name' : 'Mary Gates',
'email' : 'mg@gmail.com',
'type' : 'Member',
'status' : 'Active',
},
]
},
beforeMount(){
this.originalrows = this.rows;
},
methods : {
search() {
var results = [];
var searchData = this.originalrows;
if(this.query == ""){
this.rows = this.originalrows;
}else{
for (var i=0 ; i < searchData.length ; i++)
{
var sparam = this.query.toLowerCase();
for (var key in searchData[i]) {
if (searchData[i].hasOwnProperty(key)) {
console.log(searchData[i][key]);
var value = searchData[i][key];
if(typeof value =="string" && value.toLowerCase().indexOf(sparam) >=0){
results.push(searchData[i]);
}
}
}
}
this.rows = results;
}
console.log(results);
}
},
watch : {
query () {
this.search();
}
}
})
</script>
</body>
</html>