Subversion-Projekte lars-tiefland.ci

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
776 lars 1
var TableDatatablesScroller = function () {
2
 
3
    var initTable1 = function () {
4
        var table = $('#sample_1');
5
 
6
        var oTable = table.dataTable({
7
 
8
            // Internationalisation. For more info refer to http://datatables.net/manual/i18n
9
            "language": {
10
                "aria": {
11
                    "sortAscending": ": activate to sort column ascending",
12
                    "sortDescending": ": activate to sort column descending"
13
                },
14
                "emptyTable": "No data available in table",
15
                "info": "Showing _START_ to _END_ of _TOTAL_ entries",
16
                "infoEmpty": "No entries found",
17
                "infoFiltered": "(filtered1 from _MAX_ total entries)",
18
                "lengthMenu": "_MENU_ entries",
19
                "search": "Search:",
20
                "zeroRecords": "No matching records found"
21
            },
22
 
23
            // Or you can use remote translation file
24
            //"language": {
25
            //   url: '//cdn.datatables.net/plug-ins/3cfcc339e89/i18n/Portuguese.json'
26
            //},
27
 
28
            // setup buttons extension: http://datatables.net/extensions/buttons/
29
            buttons: [
30
                { extend: 'print', className: 'btn dark btn-outline' },
31
                { extend: 'pdf', className: 'btn green btn-outline' },
32
                { extend: 'csv', className: 'btn purple btn-outline ' }
33
            ],
34
 
35
            // scroller extension: http://datatables.net/extensions/scroller/
36
            scrollY:        300,
37
            deferRender:    true,
38
            scroller:       true,
39
 
40
            stateSave:      true,
41
 
42
            "order": [
43
                [0, 'asc']
44
            ],
45
 
46
            "lengthMenu": [
47
                [10, 15, 20, -1],
48
                [10, 15, 20, "All"] // change per page values here
49
            ],
50
            // set the initial value
51
            "pageLength": 10,
52
 
53
            "dom": "<'row' <'col-md-12'B>><'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>", // horizobtal scrollable datatable
54
 
55
            // Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
56
            // setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js).
57
            // So when dropdowns used the scrollable div should be removed.
58
            //"dom": "<'row' <'col-md-12'T>><'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
59
        });
60
    }
61
 
62
    var initTable2 = function () {
63
        var table = $('#sample_2');
64
 
65
        var oTable = table.dataTable({
66
 
67
            // Internationalisation. For more info refer to http://datatables.net/manual/i18n
68
            "language": {
69
                "aria": {
70
                    "sortAscending": ": activate to sort column ascending",
71
                    "sortDescending": ": activate to sort column descending"
72
                },
73
                "emptyTable": "No data available in table",
74
                "info": "Showing _START_ to _END_ of _TOTAL_ entries",
75
                "infoEmpty": "No entries found",
76
                "infoFiltered": "(filtered from _MAX_ total entries)",
77
                "lengthMenu": "_MENU_ entries",
78
                "search": "Search:",
79
                "zeroRecords": "Loading..."
80
            },
81
 
82
            // Or you can use remote translation file
83
            //"language": {
84
            //   url: '//cdn.datatables.net/plug-ins/3cfcc339e89/i18n/Portuguese.json'
85
            //},
86
 
87
            buttons: [
88
                { extend: 'print', className: 'btn default' },
89
                { extend: 'pdf', className: 'btn default' },
90
                { extend: 'csv', className: 'btn default' }
91
            ],
92
 
93
            // scroller extension: http://datatables.net/extensions/scroller/
94
            serverSide: true,
95
            ordering: false,
96
            searching: false,
97
            ajax: function ( data, callback, settings ) {
98
                var out = [];
99
 
100
                for ( var i=data.start, ien=data.start+data.length ; i<ien ; i++ ) {
101
                    out.push( [ i+'-1', i+'-2', i+'-3', i+'-4', i+'-5' ] );
102
                }
103
 
104
                setTimeout( function () {
105
                    callback( {
106
                        draw: data.draw,
107
                        data: out,
108
                        recordsTotal: 5000000,
109
                        recordsFiltered: 5000000
110
                    } );
111
                }, 50 );
112
            },
113
            scrollY: 400,
114
            scroller: {
115
                loadingIndicator: true
116
            },
117
 
118
            "dom": "<'row' <'col-md-12'B>><'table-scrollable't><'row'<'col-md-12'i>>"
119
        });
120
    }
121
 
122
    var initTable3 = function () {
123
        var table = $('#sample_3');
124
 
125
        var oTable = table.dataTable({
126
 
127
            // Internationalisation. For more info refer to http://datatables.net/manual/i18n
128
            "language": {
129
                "aria": {
130
                    "sortAscending": ": activate to sort column ascending",
131
                    "sortDescending": ": activate to sort column descending"
132
                },
133
                "emptyTable": "No data available in table",
134
                "info": "Showing _START_ to _END_ of _TOTAL_ entries",
135
                "infoEmpty": "No entries found",
136
                "infoFiltered": "(filtered1 from _MAX_ total entries)",
137
                "lengthMenu": "_MENU_ entries",
138
                "search": "Search:",
139
                "zeroRecords": "No matching records found"
140
            },
141
 
142
            // Or you can use remote translation file
143
            //"language": {
144
            //   url: '//cdn.datatables.net/plug-ins/3cfcc339e89/i18n/Portuguese.json'
145
            //},
146
 
147
            // setup buttons extension: http://datatables.net/extensions/buttons/
148
            buttons: [
149
                { extend: 'print', className: 'btn dark btn-outline' },
150
                { extend: 'pdf', className: 'btn green btn-outline' },
151
                { extend: 'csv', className: 'btn purple btn-outline ' }
152
            ],
153
 
154
            // scroller extension: http://datatables.net/extensions/scroller/
155
            scrollY:        300,
156
            deferRender:    true,
157
            scroller:       true,
158
            deferRender:    true,
159
            scrollX:        true,
160
            scrollCollapse: true,
161
 
162
            stateSave:      true,
163
 
164
            "order": [
165
                [0, 'asc']
166
            ],
167
 
168
            "lengthMenu": [
169
                [10, 15, 20, -1],
170
                [10, 15, 20, "All"] // change per page values here
171
            ],
172
            // set the initial value
173
            "pageLength": 10,
174
 
175
            "dom": "<'row' <'col-md-12'B>><'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>", // horizobtal scrollable datatable
176
 
177
            // Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
178
            // setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js).
179
            // So when dropdowns used the scrollable div should be removed.
180
            //"dom": "<'row' <'col-md-12'T>><'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
181
        });
182
    }
183
 
184
    var initTable4 = function () {
185
        var table = $('#sample_4');
186
 
187
        var oTable = table.dataTable({
188
 
189
            // Internationalisation. For more info refer to http://datatables.net/manual/i18n
190
            "language": {
191
                "aria": {
192
                    "sortAscending": ": activate to sort column ascending",
193
                    "sortDescending": ": activate to sort column descending"
194
                },
195
                "emptyTable": "No data available in table",
196
                "info": "Showing _START_ to _END_ of _TOTAL_ entries",
197
                "infoEmpty": "No entries found",
198
                "infoFiltered": "(filtered1 from _MAX_ total entries)",
199
                "lengthMenu": "_MENU_ entries",
200
                "search": "Search:",
201
                "zeroRecords": "No matching records found"
202
            },
203
 
204
            // Or you can use remote translation file
205
            //"language": {
206
            //   url: '//cdn.datatables.net/plug-ins/3cfcc339e89/i18n/Portuguese.json'
207
            //},
208
 
209
            // setup buttons extension: http://datatables.net/extensions/buttons/
210
            buttons: [
211
                { extend: 'print', className: 'btn dark btn-outline' },
212
                { extend: 'pdf', className: 'btn green btn-outline' },
213
                { extend: 'csv', className: 'btn purple btn-outline ' }
214
            ],
215
 
216
            // scroller extension: http://datatables.net/extensions/scroller/
217
            scrollY:        300,
218
            deferRender:    true,
219
            scroller:       true,
220
            deferRender:    true,
221
            scrollX:        true,
222
            scrollCollapse: true,
223
 
224
            "order": [
225
                [0, 'asc']
226
            ],
227
 
228
            "lengthMenu": [
229
                [10, 15, 20, -1],
230
                [10, 15, 20, "All"] // change per page values here
231
            ],
232
            // set the initial value
233
            "pageLength": 10,
234
 
235
            "dom": "<'row' <'col-md-12'B>><'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>", // horizobtal scrollable datatable
236
 
237
            // Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
238
            // setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js).
239
            // So when dropdowns used the scrollable div should be removed.
240
            //"dom": "<'row' <'col-md-12'T>><'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
241
        });
242
    }
243
 
244
    return {
245
 
246
        //main function to initiate the module
247
        init: function () {
248
 
249
            if (!jQuery().dataTable) {
250
                return;
251
            }
252
 
253
            initTable1();
254
            initTable2();
255
            initTable3();
256
            initTable4();
257
        }
258
 
259
    };
260
 
261
}();
262
 
263
jQuery(document).ready(function() {
264
    TableDatatablesScroller.init();
265
});