Spry Data References

Spry Data References are pieces of text that represent a column in the data set. They are used within spry:regions and spry:detailregions to present data from the data set in the body of the page.

There are data references from the uses data set and there are built-in data references that are always availalble to the regions. This document will describe these built-in data references.

All data references are denoted by curly braces: {data_reference}. All built-in data references begin with 'ds_', such as {ds_RowID}.

Data References can only be used in the <body> or in data set constructor scripts. They cannot be used in other functions in the head. However, most built-in data references have equivalent functions in the API.

Spry data references are used in a couple ways. First, they are used to provide basic information about the data set, like the total number of records: {ds_RowCount}. It also provides ways for users to specify specific rows in a variety of context. For instance, each row in the data set has a unique number, like the primary key in a data base. This number can always be used to identify that row. There are also references that keep track of row while doing things like looping. For instance, of you sort the data set, there is always a 'first row' of the data set {ds_rowNumber}, but depending on the sort order, the unique information in the first row might change. That data in the first row can have a different {ds_RowID}, depending on the sort.

Spry uses a 0 based counting system.

Data reference

Description

ds_CurrentRowID

The ID of the current row of the data set.

ds_CurrentRowNumber

The row number of the current row of the data set.

ds_EvenOddRow

Looks at the current value of ds_RowNumber and returns the string "even" or "odd".

ds_RowCount

The number of rows in the data set.

ds_RowID

The ID of a row in the data set.

ds_RowNumber

The row number of the current row of the data set.

ds_RowNumberPlus1

The same as ds_RowNumber, except that the first row starts at index 1 instead of index 0.

ds_SortColumn

The name of the column last used for sorting.

ds_SortOrder

The current sort order of the data in the data set.

ds_UnfilteredRowCount

The number of rows in the data set before any nondestructive filter is applied.

ds_CurrentRowID

{ds_CurrentRowID}

Description

The ID of the current row of the data set.

Each row as an unique RowID. The data set also has a concept of a 'currentRow': The active or selected row in the data set.

The {ds_CurrentRowID} is the RowID for current row of the data set.

This value does not change, even when used within a looping construct.

Example

{ds_CurrentRowID}

ds_CurrentRowNumber

{ds_CurrentRowNumber}

Description

The row number of the current row of the data set.

If there is a data set with 10 rows, there is always a first row, or fifth row, no matter what the data of that row is. This data reference returns the row number of the current row.

This value does not change, even when used within a looping, sorting or filtering construct.

Example

{ds_CurrentRowID}

ds_EvenOddRow

{ds_EvenOddRow}

Description

This data reference returns the word 'even' or 'odd', depending on the current value of the {ds_RowNumber}.

When used in the class attribute, this is useful in creating alternate row styles.

Create CSS classes called '.even' and '.odd' and style as needed.

As this data reference loops through the data set, it will write out 'even' or 'odd'.

Example

<style>
.even
{
background-color: yellow;
}
.odd
{
background-color: blue;
}

</style>

...
<tr spry:repeat="ds1" class={ds_EvenOddRow}">
...

ds_RowCount

{ds_RowCount}

Description

The number of rows in the data set.

If a nondestructive filter is set on the data set, this is the total number of rows after the filter is applied. Use {ds_UnfilteredRowCount} to display the total number of rows in the unfiltered data.

Example

<div spry:region="ds1">
Total Number of Records: {ds_RowCount}
</div>

ds_RowID

{ds_RowID}

Description

The ID of a row in the data set. This ID can be used to refer to a specific record in the data set. It does not change, even when the data is sorted.

This is often used when triggering detail regions with ds.setCurrentRow.

The spry:setrow attribute uses this value behind the scenes to trigger detail regions.

This can be programatically assigned by the developer.

By default, it is a string.

Example

<tr spry:repeat="ds1" onclick="ds1.setCurrentRow('{ds_RowID}');>

Note: We wrap the value in single quotes to deal with preparsing issues with Internet Explorer.

ds_RowNumber

{ds_RowNumber}

Description

The row number of the current row of the data set.

Within a loop construct, this number reflects the position of the row currently being evaluated.

Example

{ds_RowNumber}

ds_RowNumberPlus1

{ds_RowNumber}

Description

The same as ds_RowNumber, except that the first row starts at index 1 instead of index 0.

This is used for display purposes. Because Spry uses a zero based counting system, trying to use {ds_RowNumber} would start with 0. Using {ds_RowNumberPlus1} would start with 1, properly reflecting standard counting systems.

Example

{ds_RowNumberPlus1}

ds_SortColumn

{ds_RowNumber}

Description

The name of the column last used for sorting. If the data in the data set was never sorted, this outputs nothing (an empty string).

Example

{ds_SortColumn}

ds_SortOrder

{ds_RowNumber}

Description

The current sort order of the data in the data set. This data reference outputs the words ascending, descending, or nothing (an empty string).

Example

{ds_SortOrder}

ds_UnfilteredRowCount

{ds_RowNumber}

Description

The number of rows in the data set before any nondestructive filter is applied.

Example

{ds_UnfilteredRowCount}

function::<function name>

{function::<function name>}

Description

Invokes the JavaScript function with the specified name during region processing/markup re-generation, the function then has a chance to return a value that will be inserted directly into the markup in place of the data reference.

The signature of the function should be as follows:

function myFunction(region, lookupFunction)
{
  // Code that returns a value.
}

When the function is invoked, it will be passed 2 arguments. The first argument is the name of the region that is currently being processed/re-generated. The second argument is a function that can be used to lookup the values of data references. The lookup function is very flexible in terms of the format of the data reference it is given. For example, given a region that is bound to a data set called "ds1", the following calls to the lookup function are equivalent:

var name = lookupFunction("@name");

var name = lookupFunction("{@name}");

var name = lookupFunction("ds1::@name");

var name = lookupFunction("{ds1::@name}");

var name = lookupFunction("ds1", "@name");

Example

<script type="text/javascript">

function FormattedPrice(region, lookupFunc)
{
  // Format the number in the price column so that it
  // becomes a string that starts with a dollar sign,
  // and ends with a number that has 2 digits after
  // the decimal point.

  return "$" + parseInt(lookupFunc("{dsProducts::price}")).toFixed(2);
}

</script>

...

<div spry:region="dsProducts">
  <ul spry:repeatchildren="dsProducts">
    <li>{name} - {function::FormattedPrice}</li>
  </ul>
</div>

Copyright © 2007. Adobe Systems Incorporated.
All rights reserved.