{% if grouped_objects %}
<div class="filter-container">
<label>
    <div class="input-group">
        <script>
            function search_{{ name }}(value){
                var table = $('#pick-{{ name }}');
                if(value) {
                    table.find(".pick-value").hide();
                    table.find(".pick-grouper").hide();
                    var trs = table.find(".pick-value:icontains('" + value + "')").closest('tr');
                    trs.show();
                    trs.each(function( index ) {
                      $( this ).prev('.pick-grouper').show();
                    });
                } else {
                    table.find(".pick-grouper").show();
                    table.find(".pick-value").show();
                }
            }
        </script>
    </div>
</label>
</div>
<table id="pick-{{ name }}" class="table table-striped table-bordered table-hover">
    <thead>
        <tr>
            <th style="text-align: center; width: 15px">{{ widget }}</th>
			<th>
                Opções
            </th>
        </tr>
        <!--
        <tr>
            <th colspan="2">
                <input style="height: 34px;" type="text" class="form-control input-sm" placeholder="Filtrar por palavras-chaves..." aria-controls="dataTable" value="" onkeyup="search_{{ name }}(this.value)">
            </th>
        </tr>
        -->
    </thead>
    <tbody>
    {% for grouper, objects in grouped_objects %}
        {% if grouper %}
            <tr class="pick-grouper">
                <td colspan="2"><strong>{{ grouper }}</strong></td>
            </tr>
        {% endif %}
        {% for obj in objects %}
            <tr class="pick-value">
                <td align="center">{{ obj.widget }}</td>
                <td align="left">
                    {% for column_name, lookup in extra_display %}
                        {% if loop.first %}
                            {{ obj|getattr(lookup)|format }}
                        {% else %}
                            <strong>{{ column_name }}</strong>: {{ obj|getattr(lookup)|format }}<br>
                        {% endif %}
                    {% endfor %}
                    <span style="font-size: 0">{{ grouper }}</span>
                </td>
            </tr>
        {% endfor %}
    {% endfor %}
	</tbody>
</table>
{% endif %}
