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.
Comment 1 written by Ed on 1 November 2006, at 12:16 PM
Comment 2 written by Lola Lee Beno on 2 November 2006, at 7:53 AM
Comment 3 written by Raymond Camden on 2 November 2006, at 8:22 AM
Comment 4 written by Lola Lee Beno on 2 November 2006, at 9:07 AM
Comment 5 written by Bruce Phillips on 2 November 2006, at 12:23 PM
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
Comment 6 written by Chris on 16 November 2006, at 6:20 AM
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
Comment 7 written by Raymond Camden on 16 November 2006, at 6:27 AM
Comment 8 written by Chris on 16 November 2006, at 7:05 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.
Comment 9 written by Raymond Camden on 16 November 2006, at 7:41 AM
Comment 10 written by Chris on 17 November 2006, at 5:06 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?
Comment 11 written by Raymond Camden on 17 November 2006, at 10:07 AM
Comment 12 written by Christopher Walker on 5 June 2008, at 11:16 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.
Comment 13 written by Christopher Walker on 5 June 2008, at 11:34 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#
Comment 14 written by Raymond Camden on 5 June 2008, at 12:48 PM
Comment 15 written by Christopher Walker on 6 June 2008, at 9:21 AM
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.
Comment 16 written by Raymond Camden on 6 June 2008, at 9:34 AM
Comment 17 written by Kin Blas on 9 June 2008, at 11:28 AM
http://labs.adobe.com/technologies/spry/articles/d...
--== Kin ==--
Comment 18 written by Bill on 2 November 2008, at 8:15 PM
Comment 19 written by Raymond Camden on 3 November 2008, at 3:20 PM
[Add Comment] [Subscribe to Comments]