-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdefault_order_by.php
163 lines (127 loc) · 4.52 KB
/
default_order_by.php
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
<?php
//include config database
include "lib/config.php";?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>PHP PDO Datatable Server Side Processing Default Ordering Column </title>
<!-- Bootstrap -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet">
<!-- Datatable css -->
<link href="assets/css/dataTables.bootstrap.css" rel="stylesheet">
<!-- library chosen untuk merubah select biasa jadi searchable -->
<link href="assets/css/chosen.css" rel="stylesheet">
</head>
<body>
<div id="loader" style="display:none">
<img src="assets/images/loadnya.gif" class="ajax-loader"/>
</div>
<!-- Page Content -->
<div class="container">
<!-- Heading Row -->
<div class="row row-centered">
<h1><a href="http://wildantea.com/php-pdo-datatable-server-side-processing-order-by-column/" target="_blank">PHP PDO Datatable Server Side Processing Default Ordering Column</a></h1>
</div>
<!-- Heading Row -->
<div class="row">
<div class="col-md-6">
<h3>Order By default id provinsi secara descending </h3>
Disini id provinsi ditampilkan untuk melihat ordering sudah sesuai apa belum. Namun, Anda tak perlu menampilkan id provinsi jika tidak diinginkan.
<table id="contoh" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>NO</th>
<th>Id Provinsi</th>
<th>Provinsi</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="col-md-6">
<h3>Order By nama provinsi secara descending</h3>
<table id="contoh2" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>NO</th>
<th>Provinsi</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
<p><a href="http://wildantea.com">Main BLog</a></p>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="assets/js/jquery-1.12.0.min.js"></script>
<!-- datatables js -->
<script src="assets/js/jquery.dataTables.min.js"></script>
<script src="assets/js/dataTables.bootstrap.min.js"></script>
<!-- library select2 untuk merubah select biasa jadi searchable -->
<script src="assets/js/chosen.jquery.min.js"></script>
<!-- let's begin the script -->
<script type="text/javascript">
//simpan datatable ke variable dataTable,
var dataTable = $("#contoh").dataTable({
'bProcessing': true,
'bServerSide': true,
"deferRender": true,
'columnDefs': [
{
//set width kolom nomor dan disable ordering
'width': '5%',
'targets': 0,
'orderable': false,
'searchable': false,
'className': 'dt-center'
}
],
"ajax":{
url :"order_by_data_1.php",
type: "post", // method , by default get
//bisa kirim data ke server
/*data: function ( d ) {
d.jurusan = "3223";
},*/
error: function (xhr, error, thrown) {
console.log(xhr);
}
},
});
//untuk contoh kedua
var dataTable = $("#contoh2").dataTable({
'bProcessing': true,
'bServerSide': true,
"deferRender": true,
'columnDefs': [
{
//set width kolom nomor dan disable ordering
'width': '5%',
'targets': 0,
'orderable': false,
'searchable': false,
'className': 'dt-center'
}
],
"ajax":{
url :"order_by_data_2.php",
type: "post", // method , by default get
//bisa kirim data ke server
/*data: function ( d ) {
d.jurusan = "3223";
},*/
error: function (xhr, error, thrown) {
console.log(xhr);
}
},
});
</script>
</body>
</html>