This repository was archived by the owner on Feb 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 234
Expand file tree
/
Copy pathdatatable_js.html.twig
More file actions
104 lines (84 loc) · 3.41 KB
/
datatable_js.html.twig
File metadata and controls
104 lines (84 loc) · 3.41 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
{##
# This file is part of the SgDatatablesBundle package.
#
# (c) stwe <https://github.com/stwe/DatatablesBundle>
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#}
<script type="text/javascript">
$(document).ready(function () {
var selector = "#sg-datatables-{{ sg_datatables_view.name }}";
var oTable;
var defaults = {
};
var language = {
{% include 'SgDatatablesBundle:datatable:language.html.twig' %}
};
var ajax = {
{% include 'SgDatatablesBundle:datatable:ajax.html.twig' %}
};
var options = {
{% include 'SgDatatablesBundle:datatable:options.html.twig' %}
};
var features = {
{% include 'SgDatatablesBundle:datatable:features.html.twig' %}
};
var callbacks = {
{% include 'SgDatatablesBundle:datatable:callbacks.html.twig' %}
};
var extensions = {
{% include 'SgDatatablesBundle:datatable:extensions.html.twig' %}
};
var columns = {
{% include 'SgDatatablesBundle:datatable:columns.html.twig' %}
};
var initialSearch = {
{% include 'SgDatatablesBundle:datatable:initial_search.html.twig' %}
};
function postCreateDatatable(pipeline) {
{% for column in sg_datatables_view.columnBuilder.columns %}
{% if column.renderPostCreateDatatableJsContent is not null %}
{{ column.renderPostCreateDatatableJsContent|raw }}
{% endif %}
{% endfor %}
}
function createDatatable() {
$.extend(defaults, language);
$.extend(defaults, ajax);
$.extend(defaults, options);
$.extend(defaults, features);
$.extend(defaults, callbacks);
$.extend(defaults, extensions);
$.extend(defaults, columns);
$.extend(defaults, initialSearch);
$.extend(defaults, {
stateSaveCallback: function(settings,data) {
localStorage.setItem(settings.sInstance, JSON.stringify(data) )
},
stateLoadCallback: function(settings) {
return JSON.parse( localStorage.getItem(settings.sInstance ) )
},
});
if (!$.fn.dataTable.isDataTable(selector)) {
$(selector)
{% include 'SgDatatablesBundle:datatable:events.html.twig' %}
;
oTable = $(selector)
.DataTable(defaults)
.on('draw.dt', function() { postCreateDatatable({{ sg_datatables_view.ajax.pipeline}}) })
;
{% if true == sg_datatables_view.options.individualFiltering %}
{% include 'SgDatatablesBundle:datatable:search.js.twig' %}
{% endif %}
}
}
createDatatable();
new $.fn.dataTable.FixedColumns( oTable, {
leftColumns: 2
} );
{% if sg_datatables_view.columnBuilder.uniqueColumn('multiselect') is not null %}
{{ sg_datatables_render_multiselect_actions( sg_datatables_view.columnBuilder.uniqueColumn('multiselect'), sg_datatables_view.ajax.pipeline) }}
{% endif %}
});
</script>