Spry built-in variables for Datasets
This is mainly for my own reference - but as I always have trouble finding it - I thought I'd share. When working with Spry datasets, you have access to both the data in the set (obviously) as well as a set of built-in variables prefixed by ds_. The variables you can use:
- ds_RowID - This is 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.
- ds_RowNumber - This is 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.
- ds_RowNumberPlus1 - This is the same as ds_RowNumber except that the first row starts at index 1 instead of index 0.
- ds_RowCount - This is the number of rows in the data set. If there is a non-destructive filter set on the data set, this is the total number of rows after the filter is applied.
- ds_UnfilteredRowCount - This is the number of rows in the data set before any non-destructive filter is applied.
- ds_CurrentRowID - This is the id of the "current row" of the data set. This value will not change, even when used within a looping construct construct.
- ds_CurrentRowNumber - This is the row number of the "current row" of the data set. This value will not change, even when used within a looping construct.
- ds_SortColumn - This is the name of the column last used for sorting. If the data in the data set has never been sorted, this will output nothing (an empty string).
- ds_SortOrder - This is the current sort order of the data in the data set. This data reference will output the words "ascending", "descending", or nothing (an empty string).
- ds_EvenOddRow - This looks at the current value of ds_RowNumber and returns the string "even" or "odd". This is useful for rendering alternate row colors.
The text above was ripped from: http://labs.adobe.com/technologies/spry/articles/data_set_overview/
I'm thinking of creating a Spry cheat sheet to contain stuff like this and other tips that may be useful for development. If folks have some ideas for what to include, let me know by posting here.
Comments
# Posted By Ed
| 11/1/06 12:16 PM
# Posted By Lola Lee Beno
| 11/2/06 7:53 AM
# Posted By Raymond Camden
| 11/2/06 8:22 AM
# Posted By Lola Lee Beno
| 11/2/06 9:07 AM
http://www.brucephillips.name/blog/index.cfm/2006/...
I know that Spry is in Alpha/Beta/Pre-Release, but I'm trying to keep track of what we can use Spry for. If you have any ideas of stuff I'm missing under Spry Data Set, Effects, or Widgets let me know.
Bruce
# Posted By Bruce Phillips
| 11/2/06 12:23 PM
I searched the net and couldn't find a solution for my problem, so I decided to ask the pro's.
How do I get the current row number of all children of a dataset element.
I use spry:repeat to repeat elements of a dataset and spry:repeatchildren to repeat the children of the elements for each row.
I want to use ds_EvenOddRow to render alternate row colors for the children of the elements, but I have no clue how to do that.
Can anyone help?
Thanx in advance,
Chris
# Posted By Raymond Camden
| 11/16/06 6:27 AM
That is what I did... the CSS item renders the main elements but not the children.
The output looks like this:
1 MainElement
1 Child (class="mydataeven")
2 Child (class="mydataeven")
3 Child (class="mydataeven")
2 MainElement
1 Child (class="mydataodd")
2 Child (class="mydataodd")
And this is what I would like to have:
1 MainElement
1 Child (class="mydataeven")
2 Child (class="mydataodd")
3 Child (class="mydataeven")
2 MainElement
1 Child (class="mydataeven")
2 Child (class="mydataodd")
If I could get the row number of the child-elements, I could use spry:if to check if the row number is even or odd, but I don't know how.
# Posted By Raymond Camden
| 11/16/06 7:41 AM
sorry for the late answer.
I had to adapt the code to a simple example (we're working with MG/Reactor/ColdSpring). I'm only the designer and I'm not sure if everything is coded correctly but it should reflect the original application.
At least I could partially figure out where the problem is - it's the spry:region (when having more than one dataset).
Whereto can I send the files?
# Posted By Raymond Camden
| 11/17/06 10:07 AM
I'm working on a spry table which uses a xml dataset. Additionally, I'm using ColdFusion Report Builder to create a PDF or an Excel file (customer choice) using the screen output data. My boss loves it but now he wants to output the cfr based upon the way the customer orders the columns. So what I'm currently trying to do is pass the {ds_SortColumn} {ds_SortOrder} into the query as a ORDER BY statement. I'm having some issues, if anyone has any ideas I'd love to hear it. In the mean time I'll keep you informed.
# Posted By Christopher Walker
| 6/5/08 11:16 AM
<a href="/reports/blah_blah.cfr?sortOrder={ds_SortOrder}&column={ds_SortColumn}" target="_blank">
And the query:
<cfif ((isDefined(url.column) and (trim(url.column) neq '')) and (isDefined(url.sortOrder) and (trim(url.sortOrder) neq '')))
<cfset ORDER = 'Order By' & '#url.column#' & '#url.sortOrder#'>
<cfelse>
<cfset ORDER = ''
</cfif>
SELECT *
FROM SOMETABLE
#ORDER#
# Posted By Christopher Walker
| 6/5/08 11:34 AM
# Posted By Raymond Camden
| 6/5/08 12:48 PM
E.g.: ds_SortOrder == 'ascending'
ds_SortColumn == 'id_info'
I know it a bit more complcated than that as the info appears to be stored in a JSON object or XML dataset depending on the developer's choice. In my case I'm consuming XML data.
# Posted By Christopher Walker
| 6/6/08 9:21 AM
# Posted By Raymond Camden
| 6/6/08 9:34 AM
http://labs.adobe.com/technologies/spry/articles/d...
--== Kin ==--
# Posted By Kin Blas
| 6/9/08 11:28 AM
# Posted By Raymond Camden
| 11/3/08 3:20 PM
