template::list::filter::create (public)

 template::list::filter::create -list_name list_name \
    -filter_name filter_name -spec spec [ -ulevel ulevel ]

Defined in packages/acs-templating/tcl/list-procs.tcl

Adds a filter to a list builder list.

This proc shouldn't be called directly, only through template::list::create.

These are the available properties in the spec:

  • label: The label of the filter.
  • hide_p: Set to 1 to hide this filter from default rendering.
  • type: The type of values this filter sets. Also see 'values' below. Valid options are: 'singleval', meaning that the value is a single value of a query variable with the name of the filter; 'multival', meaning the value is really a Tcl list of values, sent to a :multiple page variable; and 'multivar', meaning that the value is a list of (key value) lists, as in { { var1 value1 } { var2 value 2 } }. 'multival' is useful when you're filtering on, say, a date range, in which case you'd send two values, namely the start and end date. 'multivar' is useful when you want the selection of one filter to change the value of another filter, for example when selecting groupby, you also want to order by the grouped by column, otherwise the groupby won't work properly (you'll get a new group each time the value changes, but it's not sorted by that column, so you'll get more than one group per value over the entire list).
  • add_url_eval: An expression which will be uplevel subst'ed with a magic variable __filter_value set to the value of the given filter.
  • values: A list of lists of possible filter values, as in { { label1 value1 count1 } { label2 value2 count2 } ... }. The 'label' is what's displayed when showing the available filter values. 'value' is what changes filter values, and, depending on 'type' above, can either be a single value, a list of values, or a list of ( name value ) pairs. 'count' is optional, and is the number of rows that match the given filter value.
  • has_default_p: If set to 1, it means that this filter has a default value, and thus cannot be cleared. If not set, the list builder will automatically provide a link to clear the currently selected value of this filter. You only need to set this if you specify a default value in your page's ad_page_contract, instead of through the 'default_value' property below.
  • default_value: The default value to use when no value is selected for this filter. Automatically sets has_default_p to 1.
  • where_clause: What should go in the where clause of your query when filtering on this filter. For example "l.project_id = :project_id".
  • where_clause_eval: Same as where_clause, except this gets evaluated in the caller's context.
  • other_label: If your values above do not carry all possible values, we can display a special 'other' value when some other value is selected for this filter. You specify here what label should be used for that element.
  • form_element_properties: If you are using filter form, additional properties to override the form element declaration. Any valid form properties can be passed using the same names are template::element::create. A list of name value pairs.

In order for filters to work, you have to specify them in your page's ad_page_contract, typically as filter_name:optional. The list builder will find them from there, by grabbing them from your page's local variables.

Switches:
-list_name
(required)
Name of list.
-filter_name
(required)
Name of the filter.
-spec
(required)
The spec for this filter. This is an array list of property/value pairs, where the right hand side is 'subst'ed in the caller's namespace, except for *_eval properties, which are 'subst'ed inside the multirow.
-ulevel
(defaults to "1") (optional)
Where we should uplevel to when doing the subst's. Defaults to '1', meaning the caller's scope.

Partial Call Graph (max 5 caller/called nodes):
%3 template::list::create template::list::create (public) template::list::filter::create template::list::filter::create template::list::create->template::list::filter::create template::list::orderby::create template::list::orderby::create (public) template::list::orderby::create->template::list::filter::create template::adp_level template::adp_level (public) template::list::filter::create->template::adp_level template::list::filter::set_properties template::list::filter::set_properties (public) template::list::filter::create->template::list::filter::set_properties template::list::get_reference template::list::get_reference (public) template::list::filter::create->template::list::get_reference

Testcases:
No testcase defined.
[ show source ]
Show another procedure: