template::list::orderby::create (public)
template::list::orderby::create -list_name list_name \ -orderby_name orderby_name -spec spec [ -ulevel ulevel ]
Defined in packages/acs-templating/tcl/list-procs.tcl
Adds an orderby 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:
It is difficult, but you can sort hierarchical queries.
- label: The label for the orderby.
- orderby: The column to use in the order by clause of the query. If it's not as simple as that, you can also specify 'orderby_asc' and 'orderby_desc' separately.
- orderby_asc: The orderby clause when sorting ascending. This is useful when you're actually sorting by two database columns.
- orderby_desc: The reverse ordering from 'orderby_asc'.
- orderby_name: The name of a named query, same functionality as orderby property.
- orderby_asc_name: The name of a named query, same functionality as orderby_asc property.
- orderby_desc_name: The name of a named query, same functionality as orderby_desc property.
- default_direction: The default order direction, 'asc' or 'desc'. Defaults to 'asc'.
- multirow_cols: If specified, we will sort the multirow in the webserver layer by the given cols.
- Switches:
- -list_name (required)
- Name of list.
- -orderby_name (required)
- Name of the orderby.
- -spec (required)
- The spec for this orderby. 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 (optional, defaults to
"1"
)- Where we should uplevel to when doing the subst's. Defaults to '1', meaning the caller's scope.
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: # Get an upvar'd reference to list_properties template::list::get_reference -name $list_name # Get the list properties lappend list_properties(orderbys) $orderby_name # We store the full element ref name, so its easy to find later lappend list_properties(orderby_refs) [get_refname -list_name $list_name -orderby_name $orderby_name] # Create the orderby properties array if {$orderby_name eq ""} { error "Invalid orderby field or spec for list '$list_name', spec: $spec" } get_reference -create -list_name $list_name -orderby_name $orderby_name # Setup element defaults array set orderby_properties { label {} orderby_desc {} orderby_asc {} multirow_cols {} orderby {} default_direction asc } # These attributes are internal listbuilder attributes array set orderby_properties { } # Let the orderby know its own name set orderby_properties(name) $orderby_name # Let the orderby know its owner's name set orderby_properties(list_name) $list_name incr ulevel set_properties -list_name $list_name -orderby_name $orderby_name -spec $spec -ulevel $ulevel # Set the orderby properties of the element with the same name, if any template::list::element::get_reference -create -list_name $list_name -element_name $orderby_name if { [info exists element_properties] } { set element_properties(orderby_asc) $orderby_properties(orderby_asc) set element_properties(orderby_desc) $orderby_properties(orderby_desc) set element_properties(multirow_cols) $orderby_properties(multirow_cols) set element_properties(default_direction) $orderby_properties(default_direction) } # Create the 'orderby' filter if it doesn't already exist if { ![template::list::filter::exists_p -list_name $list_name -filter_name $list_properties(orderby_name)] } { template::list::filter::create -list_name $list_name -filter_name $list_properties(orderby_name) -spec [list label [_ acs-templating.Sort_order]] -ulevel 2 } template::list::filter::get_reference -list_name $list_name -filter_name $list_properties(orderby_name) lappend filter_properties(values) [list $orderby_properties(label) "${orderby_name},$orderby_properties(default_direction)"] # Return an element which can be put into the 'values' property of a filter return [list $orderby_properties(label) "${orderby_name},$orderby_properties(default_direction)"]XQL Not present: Generic, PostgreSQL, Oracle