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 pathselect.html.twig
More file actions
114 lines (99 loc) · 3.71 KB
/
select.html.twig
File metadata and controls
114 lines (99 loc) · 3.71 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
{##
# 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.
#}
{% set filter_select_multiple %}
{% if column.filter.multiple is same as(true) %}
multiple="multiple"
{% endif %}
{% endset %}
{%- set filter_id_selector -%}
sg-datatables-{{ datatable_name }}-{{ position }}-filter-{{ column.index }}
{%- endset -%}
{%- set filter_selector -%}
id="{{ filter_id_selector }}"
{%- endset -%}
{% set filter_classes %}
class="sg-datatables-individual-filtering{% if column.filter.classes is not same as(null) %} {{ column.filter.classes }}{% endif %}"
{% endset %}
{% set filter_width %}
{% if column.width is not same as(null) %}style="width:{{ column.width }};"{% endif %}
{% endset %}
{% set filter_search_column_index %}
data-search-column-index="{{ search_column_index }}"
{% endset %}
{% set filter_column_name %}
{% if column.name is not same as(null) %}name="{{ column.name }}"{% endif %}
{% endset %}
{% set filter_select_initial_search %}
{% if column.filter.initialSearch is not same as(null) %}
<option value="{{ column.filter.initialSearch }}">
{{ column.filter.searchColumn }}
</option>
{% endif %}
{% endset %}
{% set filter_select_select_options %}
{% for key, name in column.filter.selectOptions %}
<option value="{{ key }}">{{ name }}</option>
{% endfor %}
{% endset %}
{%- set cancel_button_id_selector -%}
sg-datatables-{{ datatable_name }}-{{ position }}-filter-cancel-{{ column.index }}
{%- endset -%}
{% set cancel_button_html %}
{% if column.filter.cancelButton is same as(true) %}
<button type="button"
id="{{ cancel_button_id_selector }}"
class="btn btn-default btn-xs"
>×</button>
{% endif %}
{% endset %}
{% set cancel_button_js %}
{% if column.filter.cancelButton is same as(true) %}
<script type="text/javascript">
$("#{{ cancel_button_id_selector }}").click(function() {
if ('' != $("#{{ filter_id_selector }}").val()) {
$("#{{ filter_id_selector }}")
.val('')
.change();
}
});
</script>
{% endif %}
{% endset %}
{% block html %}
<select
{{ filter_select_multiple }} {# multiple="multiple" #}
{{ filter_selector }} {# id="" #}
{{ filter_classes }} {# class="" #}
{{ filter_width }} {# style = "width:" #}
{{ filter_search_column_index }} {# data-search-column-index = "" #}
{{ filter_column_name }} {# name = "" #}
>
{{ filter_select_initial_search }} {# <option value=""></option> #}
{{ filter_select_select_options }}
</select>
<script type="text/javascript">
var currentValue = ""
if (typeof(Storage) !== "undefined") {
var datatableState = localStorage['sg-datatables-{{ datatable_name }}'];
if(datatableState){
datatableState = JSON.parse(datatableState);
var columns = datatableState['columns'];
currentValue = columns[{{ search_column_index }}]['search']['search'];
{% if column.filter.multiple is same as(true) %}
currentValue = currentValue.split(",");
{% endif %}
}
}
$("#{{ filter_id_selector }}").val(currentValue);
</script>
{{ cancel_button_html }}
{% endblock %}
{% block javascript %}
{{ cancel_button_js }}
{% endblock %}