荣誉
翻译:tinyfool

Google混搭编辑器(Google Mashup Editor) - 过滤数据

Google Mashup Editor (GME) includes tags for modifying the data users see from feeds by filtering the source of the data. This document describes the gm:filter tag and how you can use it in your GME applications.

Contents

Filtering Data

When you display a data source in a gm:list tag, you can use the gm:filter tag to narrow the displayed data to entries that pass through the filter. You can specify two kinds of filters, value and range:

You can filter on many common types of elements that appear in built-in feeds. For more information on the types of elements you can use in a gm:filter tag, see Preferred Elements.

Note that the filtering takes place on the server, before you read data from the feed -- your application never sees data that's filtered out.

Here's a simple example that uses filtering with gm:filter:

<gm:page title="filter">

<gm:list id="myList" data="${user}/filterme" template="filterTemplate">
<gm:filter ref="atom:title" value="danger" /> </gm:list> <gm:template id="filterTemplate">
<table>
<tr>
<td>Title</td>
<td>Content</td>
</tr>
<tr repeat="true">
<td> <gm:text ref="atom:title"/> </td>
<td> <gm:text ref="atom:content"/> </td>
<td> <gm:editButtons text="false"/> </td>
</tr>
</table>
<gm:create label="Add a row"/>
</gm:template>
</gm:page>

In this example, we display a two-column list of data from a ${user} feed. In the gm:list tag, we apply a gm:filter that looks for entries that exactly match the word "danger" in the atom:title element. Only entries that match this filter exactly will be displayed. If the user adds new entries to the feed, once they are saved, they must meet the filter criteria in order to be displayed.

Data Order and Sorting

When you read data from the ${app} or ${user} feeds, the data elements will be in the same order they were in when you stored them. Coming soon: we're working on a fast and easy way to sort data you read from feeds.

Preferred Elements

The following table lists the feed elements that you can use in a gm:filter tag.

Element path Description/link to more info
atom:title title element, as in ${app} and ${user} feeds.
gd:when/@startTime Event starting time.
gd:when/@endTime Event ending time.
gd:email/@address Email address.
gd:email/@label Descriptive name (e.g. "work", "home") for email address.
gd:where/@label Descriptive name (e.g. "Kirby Plaza", "main building") for location.
gd:where/@valueString Primary description of location.
gd:who/@valueString Name of participant.
gd:who/@email Participant email address.
gd:rating/@value Value of a numeric rating.