{% extends "admin/base_site.html" %} {% load i18n %} {% block bodyclass %}grp-doc{% endblock %} {% block content-class %}{% endblock %} {% block title %}Grappelli Documentation » Filter{% endblock %} {% block extrahead %} {% endblock %} {% block breadcrumbs %} {% endblock %} {% block content %}

Filter

Basics

A filter is meant to appear in a .grp-row within a .grp-module. It is a .grp-filter containing an .grp-pulldown-container with an a.grp-button.grp-pulldown-handler and a div.grp-pulldown-content. The div.grp-pulldown-content itself contains a .grp-module for each filter. Each choice is represented in a .grp-row. Please note that you have to use javascript to make the pulldown work (see source code below).

You can use filters in two predefined ways: as selects and as listings (more information below).

Note: Make sure to wrap the filter with spaceless-tags to avoid whitespaces.

Filter
{% filter force_escape %}
{% templatetag openblock %} spaceless {% templatetag closeblock %}
Filter
{% templatetag openblock %} endspaceless {% templatetag closeblock %}
{% endfilter %}
{% filter force_escape %}
(function($) {
    $(document).ready(function() {
        $("a.grp-pulldown-handler").click(function() {
            var pulldownContainer = $(this).closest(".grp-pulldown-container");
            $(pulldownContainer).toggleClass("grp-pulldown-state-open").children(".grp-pulldown-content").toggle();
        });
        $("a.grp-pulldown-handler").bind('mouseout', function() {
            $(this).blur();
        });
        $(".grp-filter-choice").change(function(){
            location.href = $(this).val();
        });
    });
})(grp.jQuery);
                    {% endfilter %}

Filters as a Select

Each filter is represented by a .grp-module containing a select where the choices are options.

Filter
{% filter force_escape %}
{% templatetag openblock %} spaceless {% templatetag closeblock %}
Filter
{% templatetag openblock %} endspaceless {% templatetag closeblock %}
{% endfilter %}

Filters as a Listing

Each filter is represented by a .grp-module where the choices are .grp-rows.

{% filter force_escape %}
{% templatetag openblock %} spaceless {% templatetag closeblock %} {% templatetag openblock %} endspaceless {% templatetag closeblock %}
{% endfilter %}
{% endblock %}