{# ------------------------------------------------------ grid ------------------------------------------------------ #} {% block grid %}
{% if grid.totalCount > 0 or grid.isFiltered or grid.noDataMessage is sameas(false) %}
{% if grid.massActions|length > 0 %} {{ grid_actions(grid) }} {% endif %}
{% if grid.isTitleSectionVisible %} {{ grid_titles(grid) }} {% endif %} {% if grid.isFilterSectionVisible %} {{ grid_filters(grid) }} {% endif %} {{ grid_rows(grid) }}
{% if withjs %} {{ grid_scripts(grid) }} {% endif %}
{% else %} {{ grid_no_data(grid) }} {% endif %}
{% endblock grid %} {# --------------------------------------------------- grid_no_data ------------------------------------------------- #} {% block grid_no_data %}

{{ grid.noDataMessage|default('No data')|trans|raw }}

{% endblock grid_no_data %} {# --------------------------------------------------- grid_no_result ------------------------------------------------- #} {% block grid_no_result %} {% spaceless %} {% set nbColumns = 0 %} {% for column in grid.columns %} {% if column.visible(grid.isReadyForExport) %} {% set nbColumns = nbColumns + 1 %} {% endif %} {% endfor %} {{ grid.noResultMessage|default('No result')|trans|raw }} {% endspaceless %} {% endblock grid_no_result %} {# --------------------------------------------------- grid_titles -------------------------------------------------- #} {% block grid_titles %} {% for column in grid.columns %} {% if column.visible(grid.isReadyForExport) %} -1) %} style="width:{{ column.size }}px;"{% endif %}> {%- spaceless %} {% if column.type == 'massaction' %} {% else %} {% if column.usePrefixTitle == true %} {% set columnTitle = grid.prefixTitle ~ column.title ~ '__abbr' %} {% if columnTitle|trans == columnTitle %} {% set columnTitle = grid.prefixTitle ~ column.title %} {% endif %} {% else %} {% set columnTitle = column.title %} {% endif %} {% if (column.sortable) %} {{ columnTitle|trans }} {% if column.order == 'asc' %}
{% elseif column.order == 'desc' %}
{% endif %} {% else %} {{ columnTitle|trans }} {% endif %} {% endif %} {% endspaceless -%} {% endif %} {% endfor %} {% endblock grid_titles %} {# -------------------------------------------------- grid_filters -------------------------------------------------- #} {% block grid_filters %} {% for column in grid.columns %} {% if column.visible(grid.isReadyForExport) %} -1) %} style="width:{{ column.size }}px;"{% endif %}>{% if column.filterable %}{{ grid_filter(column, grid)|raw }}{% endif %} {% endif %} {% endfor %} {% endblock grid_filters %} {# -------------------------------------------------- grid_search -------------------------------------------------- #} {% block grid_search %} {% if grid.isFilterSectionVisible %} {% endif %} {% endblock grid_search %} {# ---------------------------------------------------- grid_rows --------------------------------------------------- #} {% block grid_rows %} {% for row in grid.rows %} {% set last_row = loop.last %} {% spaceless %} {% set gridColumns %} {% for column in grid.columns %} {% if column.visible(grid.isReadyForExport) %} {{ grid_cell(column, row, grid)|raw }} {% endif %} {% endfor %} {% endset %} {{ gridColumns }} {% endspaceless %} {% else %} {{ grid_no_result(grid) }} {% endfor %} {% endblock grid_rows %} {# ---------------------------------------------------- grid_pager -------------------------------------------------- #} {% block grid_pager %} {% if pagerfanta %} {{ grid_pagerfanta(grid) }} {% else %}
{{ grid_pager_totalcount(grid) }} {{ grid_pager_selectpage(grid) }} {{ grid_pager_results_perpage(grid) }}
{% endif %} {% endblock grid_pager %} {# ---------------------------------------------------- grid_pager_totalcount -------------------------------------------------- #} {% block grid_pager_totalcount %} {{ '%count% Results, ' | transchoice(grid.totalCount, {'%count%': grid.totalCount}) }} {% endblock grid_pager_totalcount %} {# ---------------------------------------------------- grid_pager_selectpage -------------------------------------------------- #} {% block grid_pager_selectpage %} {{ 'Page'|trans }} {% spaceless %} = grid.pageCount-1 %}disabled="disabled"{% endif %} onclick="return {{ grid.hash }}_nextPage();"/> {{ 'of %count%'|trans({ '%count%' : grid.pageCount }) }} {% endspaceless %} {% endblock grid_pager_selectpage %} {# ---------------------------------------------------- grid_pager_results_perpage -------------------------------------------------- #} {% block grid_pager_results_perpage %} {{ ', Display'|trans }} {{ 'Items per page'|trans }} {% endblock grid_pager_results_perpage %} {# --------------------------------------------------- grid_actions ------------------------------------------------- #} {% block grid_actions %}
{{ 'Select visible'|trans }} | {{ 'Deselect visible'|trans }} | {{ 'Select all'|trans }} | {{ 'Deselect all'|trans }} {% spaceless %}
{{ 'Action'|trans }}
{% endspaceless %}
{% endblock grid_actions %} {# --------------------------------------------------- grid_exports ------------------------------------------------- #} {% block grid_exports %}
{% spaceless %} {{ 'Export'|trans }} {% endspaceless %}
{% endblock grid_exports %} {# --------------------------------------------------- grid_tweaks ------------------------------------------------- #} {% block grid_tweaks %}
{% spaceless %} {{ 'Tweaks'|trans }} {% endspaceless %}
{% endblock grid_tweaks %} {# ------------------------------------------------ grid_column_actions_cell --------------------------------------------- #} {% block grid_column_actions_cell %} {% set actions = column.getActionsToRender(row) %} {% endblock grid_column_actions_cell %} {# ------------------------------------------------ grid_column_massaction_cell --------------------------------------------- #} {% block grid_column_massaction_cell %} {% endblock grid_column_massaction_cell %} {# ------------------------------------------------ grid_column_type_boolean_cell --------------------------------------------- #} {% block grid_column_boolean_cell %} {{ block('grid_column_cell') }} {% endblock grid_column_boolean_cell %} {% block grid_column_type_boolean_cell %} {{ block('grid_column_boolean_cell') }} {% endblock grid_column_type_boolean_cell %} {# ------------------------------------------------ grid_column_type_rank_cell --------------------------------------------- #} {% block grid_column_rank_cell %} {{ grid.page * grid.limit + value }} {% endblock grid_column_rank_cell %} {% block grid_column_type_rank_cell %} {{ block('grid_column_rank_cell') }} {% endblock grid_column_type_rank_cell %} {# ------------------------------------------------ grid_column_type_array_columns --------------------------------------------- #} {% block grid_column_array_cell %} {% set sourceValues = row.field(column.id) %} {% set values = value %} {% for key, index in values -%} {% set value = index %} {% set sourceValue = sourceValues[key] %} {{ block('grid_column_cell') | raw }}{{ column.separator | raw }} {%- endfor %} {% endblock grid_column_array_cell %} {% block grid_column_type_array_cell %} {{ block('grid_column_array_cell') }} {% endblock grid_column_type_array_cell %} {# ------------------------------------------------ grid_column_type_join_cell --------------------------------------------- #} {% block grid_column_join_cell %} {% for key, index in column.joinColumns -%} {% set value = row.field(index) %} {% set sourceValue = value %} {{ block('grid_column_cell') | raw }}{{ column.separator | raw }} {%- endfor %} {% endblock grid_column_join_cell %} {% block grid_column_type_join_cell %} {{ block('grid_column_join_cell') }} {% endblock grid_column_type_join_cell %} {# ------------------------------------------- grid_column_cell ---------------------------------------- #} {% block grid_column_cell %} {%- spaceless %} {% if column.filterable and column.searchOnClick %} {% set sourceValue = sourceValue is defined ? sourceValue : row.field(column.id) %} {{ value }} {% elseif column.safe is sameas(false) %} {{ value|raw }} {% else %} {{ value|escape(column.safe)|raw }} {% endif %} {% endspaceless -%} {% endblock grid_column_cell %} {# -------------------------------------------- grid_column_operator --------------------------------------- #} {% block grid_column_operator %} {% if column.operatorsVisible %} {% endif %} {% endblock grid_column_operator %} {# -------------------------------------------- grid_column_filter_type_input --------------------------------------- #} {% block grid_column_filter_type_input %} {% set btwOperator = constant('APY\\DataGridBundle\\Grid\\Column\\Column::OPERATOR_BTW') %} {% set btweOperator = constant('APY\\DataGridBundle\\Grid\\Column\\Column::OPERATOR_BTWE') %} {% set isNullOperator = constant('APY\\DataGridBundle\\Grid\\Column\\Column::OPERATOR_ISNULL') %} {% set isNotNullOperator = constant('APY\\DataGridBundle\\Grid\\Column\\Column::OPERATOR_ISNOTNULL') %} {% set op = column.data.operator is defined ? column.data.operator : column.defaultOperator %} {% set from = column.data.from is defined ? column.data.from : null %} {% set to = column.data.to is defined ? column.data.to : null %} {{ grid_column_operator(column, grid, op, submitOnChange) }} {% endblock grid_column_filter_type_input %} {# -------------------------------------------- grid_column_filter_type_select --------------------------------------- #} {% block grid_column_filter_type_select %} {% set btwOperator = constant('APY\\DataGridBundle\\Grid\\Column\\Column::OPERATOR_BTW') %} {% set btweOperator = constant('APY\\DataGridBundle\\Grid\\Column\\Column::OPERATOR_BTWE') %} {% set isNullOperator = constant('APY\\DataGridBundle\\Grid\\Column\\Column::OPERATOR_ISNULL') %} {% set isNotNullOperator = constant('APY\\DataGridBundle\\Grid\\Column\\Column::OPERATOR_ISNOTNULL') %} {% set op = column.data.operator is defined ? column.data.operator : column.defaultOperator %} {% set from = column.data.from is defined ? column.data.from : null %} {% set to = column.data.to is defined ? column.data.to : null %} {% set multiple = column.selectMulti %} {% set expanded = column.selectExpanded %} {{ grid_column_operator(column, grid, op, submitOnChange) }} {% if expanded %} {% for key, value in column.values %} {% endfor %} {% for key, value in column.values %} {% endfor %} {% if multiple %}{% endif %} {% else %} {% for key, value in column.values %} {% endfor %} {% if multiple %}{% endif %} {% endif %} {% endblock grid_column_filter_type_select %} {# -------------------------------------------- grid_column_filter_type_massaction --------------------------------------- #} {% block grid_column_filter_type_massaction %} {% endblock grid_column_filter_type_massaction %} {# -------------------------------------------- grid_column_filter_type_massaction_filter --------------------------------------- #} {% block grid_column_filter_type_actions %} {{ 'Reset'|trans }} {% endblock grid_column_filter_type_actions %} {# --------------------------------------------------- grid_scripts -------------------------------------------------- #} {% block grid_scripts %} {% endblock grid_scripts %} {% block grid_scripts_goto %} function {{ grid.hash }}_goto(url) { window.location.href = url; return false; } {% endblock grid_scripts_goto %} {% block grid_scripts_reset %} function {{ grid.hash }}_reset() { {{ grid.hash }}_goto('{{ grid_url('reset', grid) }}'); return false; } {% endblock grid_scripts_reset %} {% block grid_scripts_previous_page %} function {{ grid.hash }}_previousPage() { {{ grid.hash }}_goto('{{ grid_url('page', grid, grid.page - 1) }}'); return false; } {% endblock grid_scripts_previous_page %} {% block grid_scripts_next_page %} function {{ grid.hash }}_nextPage() { {{ grid.hash }}_goto('{{ grid_url('page', grid, grid.page + 1) }}'); return false; } {% endblock grid_scripts_next_page %} {% block grid_scripts_enter_page %} function {{ grid.hash }}_enterPage(event, page) { key = event.which; if (window.event) { key = window.event.keyCode; //IE } if (key == 13) { {{ grid.hash }}_goto('{{ grid_url('page', grid) }}' + page); return false; } } {% endblock grid_scripts_enter_page %} {% block grid_scripts_results_per_page %} function {{ grid.hash }}_resultsPerPage(limit) { {{ grid.hash }}_goto('{{ grid_url('limit', grid) }}' + limit); return true; } {% endblock grid_scripts_results_per_page %} {% block grid_scripts_mark_visible %} function {{ grid.hash }}_markVisible(select) { var form = document.getElementById('{{ grid.hash }}'); var counter = 0; for (var i=0; i < form.elements.length; i++ ) { if (form.elements[i].type == 'checkbox') { form.elements[i].checked = select; if (form.elements[i].checked){ counter++; } } } {% if grid.isFilterSectionVisible %} counter--; {% endif %} var selected = document.getElementById('{{ grid.hash }}_mass_action_selected'); selected.innerHTML = counter > 0 ? '{{ 'Selected _s_ rows'|trans }}'.replace('_s_', counter) : ''; document.getElementById('{{ grid.hash }}_mass_action_all').value = '0'; return false; } {% endblock grid_scripts_mark_visible %} {% block grid_scripts_mark_all %} function {{ grid.hash }}_markAll(select) { var form = document.getElementById('{{ grid.hash }}'); for (var i=0; i < form.elements.length; i++ ) { if (form.elements[i].type == 'checkbox') { form.elements[i].checked = select; } } var selected = document.getElementById('{{ grid.hash }}_mass_action_selected'); if (select) { document.getElementById('{{ grid.hash }}_mass_action_all').value = '1'; selected.innerHTML = '{{ 'Selected _s_ rows'|trans }}'.replace('_s_', '{{ grid.totalCount }}'); } else { document.getElementById('{{ grid.hash }}_mass_action_all').value = '0'; selected.innerHTML = ''; } return false; } {% endblock grid_scripts_mark_all %} {% block grid_scripts_switch_operator %} {% set btwOperator = constant('APY\\DataGridBundle\\Grid\\Column\\Column::OPERATOR_BTW') %} {% set btweOperator = constant('APY\\DataGridBundle\\Grid\\Column\\Column::OPERATOR_BTWE') %} {% set isNullOperator = constant('APY\\DataGridBundle\\Grid\\Column\\Column::OPERATOR_ISNULL') %} {% set isNotNullOperator = constant('APY\\DataGridBundle\\Grid\\Column\\Column::OPERATOR_ISNOTNULL') %} function {{ grid.hash }}_switchOperator(elt, query_, submitOnChange) { submitOnChange = (typeof submitOnChange == 'undefined') ? true : submitOnChange; var inputFrom = document.getElementById(query_+'from'); var inputTo = document.getElementById(query_+'to'); if ((elt.options[elt.selectedIndex].value == '{{ btwOperator }}') || (elt.options[elt.selectedIndex].value == '{{ btweOperator }}')) { inputFrom.style.display = ''; inputFrom.disabled=false; inputTo.style.display = ''; inputTo.disabled=false; } else if ((elt.options[elt.selectedIndex].value == '{{ isNullOperator }}') || (elt.options[elt.selectedIndex].value == '{{ isNotNullOperator }}')) { inputFrom.style.display = 'none'; inputFrom.disabled=true; inputTo.style.display = 'none'; inputTo.disabled=true; if (submitOnChange) { elt.form.submit(); } } else { inputFrom.style.display = ''; inputFrom.disabled=false; inputTo.style.display = 'none'; inputTo.disabled=true; } } {% endblock grid_scripts_switch_operator %} {% block grid_scripts_submit_form %} function {{ grid.hash }}_submitForm(event, form) { key = event.which; if (window.event) { key = window.event.keyCode; //IE } if (event.type != 'keypress' || key == 13) { form.submit(); } return true; } {% endblock grid_scripts_submit_form %} {% block grid_scripts_ajax %} {% endblock grid_scripts_ajax %}