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:

  • 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.
It is difficult, but you can sort hierarchical queries.

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
(defaults to "1") (optional)
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):
%3 template::list::create template::list::create (public) template::list::orderby::create template::list::orderby::create template::list::create->template::list::orderby::create template::list::element::create template::list::element::create (public) template::list::element::create->template::list::orderby::create _ _ (public) template::list::orderby::create->_ template::list::element::get_reference template::list::element::get_reference (public) template::list::orderby::create->template::list::element::get_reference template::list::filter::create template::list::filter::create (public) template::list::orderby::create->template::list::filter::create template::list::filter::exists_p template::list::filter::exists_p (public) template::list::orderby::create->template::list::filter::exists_p template::list::filter::get_reference template::list::filter::get_reference (public) template::list::orderby::create->template::list::filter::get_reference

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
[ hide source ] | [ make this the default ]
Show another procedure: