-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatatable.html
More file actions
136 lines (119 loc) · 4.63 KB
/
Datatable.html
File metadata and controls
136 lines (119 loc) · 4.63 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
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
<style type="text/css"> @import "http://code.jquery.com/ui/1.9.2/themes/smoothness/jquery-ui.css";</style>
<!-- feuille de style pour le tableau -->
<style type="text/css" title="currentStyle">
/*
* DataTables framework
*/
div.dataTables_wrapper {
background-color: #FFF;
}
div.dataTables_length {
float: left;
}
div.dataTables_filter {
float: right;
}
div.dataTables_info {
padding: 9px 6px 6px 6px;
float: left;
}
div.dataTables_paginate {
float: right;
}
div.dataTables_length,
div.dataTables_filter,
div.dataTables_paginate {
padding: 12px;
}
</style>
<script src="http://jquery-csv.googlecode.com/files/jquery.csv-0.71.js"></script>
<script>
// build HTML table data from an array (one or two dimensional)
function generateTable(data) {
var i=0;
var html = '';
if(typeof(data[0]) === 'undefined') {
return null;
}
if(data[0].constructor === Array) {
for(var row in data) {
html += '<tr>\r\n';
for(var item in data[row]) {
html += '<td><pre>' + data[row][item] + '</pre></td>\r\n';
}
html += '</tr>\r\n';
}
}
return html;
}
// MAIN - Show a CSV file
$(document).ready(function() {
//cache disabling
var ie_fix = new Date().getTime();
$.ajaxSetup({cache: false});
var URL = "./Export.csv";
$.get(URL, function (inputstream) {
//Need to be in UTF encoding
data = $.csv.toArrays(inputstream,
{delimiter:';', // sets a custom text delimiter character
separator:';', // sets a custom field separator character
//escaper:'\', // sets a custom escape character
skip: 1} // skips lines
);
var html = generateTable(data);
$('#myTable').empty();
$('#dataOfTable').html(html);
$('#MyTable').dataTable( {
"bFilter": true,
"bInfo": true,
"bAutoWidth": true,
"bJQueryUI": true,
//"sPaginationType": "full_numbers",
"aoColumns": [
/* Code */ null,
/* Statut */ { "bVisible": false },
/* Motif */ null,
/* Designation */ null,
/* Descritpion */ { "bVisible": false },
/* Date de MAJ */ null
],
//"sScrollY": "100%",
"bPaginate": true,
"oLanguage": {
"sSearch": "Rechercher",
"sLengthMenu": "Affiche _MENU_ enregistrements par page",
"sZeroRecords": "Aucune donnée à afficher",
"sInfo": "_START_ sur _END_ de _TOTAL_ lignes",
"sInfoEmpty": "0 ligne",
"sInfoFiltered": "(filtre sur _MAX_ lignes total)"
},
//sur la colnne 'Statut' non visible
"aaSorting": [[ 1, "desc" ]]
} );
})
});
</script>
<table cellpadding="1" cellspacing="0" border="0" class="display" id="MyTable" class="display" width="100%" >
<!--en-tête obligatoire pour le framework datatable-->
<thead>
<tr >
<td width="5%" align="center" valign="center" >
Code </td>
<td width="5%" align="center" valign="center" >
Statut</td>
<td width="15%" align="center" valign="center" >
Motif</td>
<td width="75%" align="center" valign="center" >
Désignation</td>
<td width="75%" align="center" valign="center" >
Description</td>
<td width="5%" align="center" valign="center" >
Dernière mise à jour</td>
</tr>
</thead>
<tbody id="dataOfTable">
</tbody>
</table>