287
edits
(2 intermediate revisions by the same user not shown) | |||
Line 134: | Line 134: | ||
</pre> | </pre> | ||
The multiple flag may be used | The multiple flag may be used for simple 'or' expressions: | ||
<pre> | <pre> | ||
Line 142: | Line 142: | ||
The example above will match if ?name is either fred, sarah or robert. Don't put any spaces between the commas. | The example above will match if ?name is either fred, sarah or robert. Don't put any spaces between the commas. | ||
You can, of course, use multiple <where> elements. All of them must match for content to be generated. If a <where> condition does not match, | You can, of course, use multiple <where> elements. All of them must match for content to be generated. If a <where> condition does not match, no content will be generated for that item and rule, although another rule may still match. | ||
==Controlling Recursion== | ==Controlling Recursion== | ||
Line 170: | Line 170: | ||
==Template Builder API Functionality== | ==Template Builder API Functionality== | ||
Some new template builder APIs of the nsIXULTemplateBuilder interface are available. This object can be retrieved using the builder property, the one that is commonly used to call rebuild. This may be used with chrome applications, although some of these may be | Some new template builder APIs of the nsIXULTemplateBuilder interface are available. This object can be retrieved using the builder property, the one that is commonly used to call rebuild. This may be used with chrome applications, although some of these may be available for non-priviledged applications in the future. To get a result that has been generated by the template: | ||
var result = builder.getResultForId(id); | var result = builder.getResultForId(id); | ||
This method returns a result which implements nsIXULTemplateResult for a given id. This may be convenient instead of using the DOM or tree APIs to get information about a particular generated result. | This method returns a result which implements nsIXULTemplateResult for a given id. This may be convenient instead of using the DOM or tree APIs to get information about a particular generated result. | ||
==Sorting== | |||
Sorting of results may be done by using the sort and sortDirection attributes. | |||
<listbox datasources="..." ref="..." | |||
sort="key" sortDirection="ascending"/> | |||
The sort attribute is a key or keys to sort on. It may be a template variable like '?name'. For RDF queries using the simple syntax, it may be the full predicate prefixed with 'rdf:'. For example, 'rdf:http://home.netscape.com/NC-rdf#Name'. | |||
Multiple sort keys may be used, seperated by spaces. | |||
The sortDirection attribute should be set to 'ascending', 'descending' or 'natural'. This last value is the default and displays results in no particular order, although they will appear in Seq order for RDF datasources. | |||
Trees also support sorting using a similar syntax, however the sort and sortDirection attributes should be placed on <treecol> elements instead. | |||
The sortActive attribute set to true indicates which column is actively sorted. | |||
The XUL Sort Service may be used to sort a XUL element: | |||
var xs = Components.classes["@mozilla.org/xul/xul-sort-service;1"]. | |||
getService(Components.interfaces.nsIXULSortService); | |||
xs.sort(element, "?name", "ascending"); | |||
where the arguments to the sort function are the element to sort, the sort key (or multiple keys separated by spaces), and the sort direction. | |||
You may also sort non-template generated content using the sort function. In this case, the children of 'element' are sorted and the sort key is an attribute of those children to sort by. |
edits