1.32 Get Current Cell Row/Column Value

July 6th, 2013 Posted in Uncategorized

Get the current Cell’s Row/Column Value

GridRowColumnValue(row or column name)

GridRowColumnValue(row or column name, index)

For the current cell being printed, these functions return the value in its row header or its column header (the labels along the side of the grid). When there is more than one field in a row/column, make sure to specify the correct field to get the row header you want.

If the Index parameter is empty, the function will return the value for the row/column name of the current cell being printed. Let’s look at a few examples – and look at each example carefully to see how passing a different row field name tells Crystal Reports which row header value you want returned.

For Cell 1, GridRowColumnValue(“Product_Type.Product Type Name”) returns “Gloves”.

For Cell 1, GridRowColumnValue(“Product.Product Name”) returns “Active Outdoors Crochet Glove”.

For Cell 4, GridRowColumnValue(“Product.Product Name”) returns “Romeo”

For Cell 1, GridRowColumnValue(“Orders.Order Date”) returns 1/3/2004.

For Cell 4, GridRowColumnValue(“Orders.Order Date”, 1) returns 4/7/2004.

If you recall from the previous section, when grouping on date fields, the exact value that Crystal Reports associates with a specific column is based upon the first record read for each group. That is why the dates shown in the previous two examples seem a bit random. You would only know what they are supposed to be if you had the database open on your computer.

This function has an optional second parameter that is passed the index number of a row or column. This tells Crystal Reports to not print the row/column header for the current cell, but for the cell of a specific row/column index.

You have to be careful when passing the index number because it is not the row/column index number of the entire cross-tab object. It is the index number within the current group. For each group in the cross-tab object, the index number is reset back to zero. This can get a little tricky because when you call this on the current cell being printed, Crystal Reports looks at the group that the cell is located in, and starts counting the index based on the first row in that group. Let’s look at some examples.

From our previous examples, we know that the row index of Cell 1 is 4 because it is the fifth row in the cross-tab object. But this is not the index number we would pass to the GridRowColumnValue() function. Cell 1 is actually the first row within “Gloves” group. Thus, its index is 0.

For Cell 1, GridRowColumnValue(“Product.Product Name”, 0) returns “Active Outdoors Crochet Glove”.

For Cell 1, GridRowColumnValue(“Product.Product Name”, 2) returns “Influx Crochet Glove”.

For Cell 4, GridRowColumnValue(“Product.Product Name”, 1) returns “Wheeler”.

Note: If you use the option to customize the group field name, this formula still displays the underlying field value, not the custom name. For example, if you group on Customer ID, and display the Customer Name as the custom field name, the GridRowColumnValue() function still returns the Customer ID. If you want to get the custom name that is printed on the cross-tab object, see the next function GridLabelAt().

GridLabelAt(Row or Column Name, Row/Column Index)

GridLabelAt () returns the label for the row/column specified. Pass it a group’s field name and the row or column index. If you chose the option to customize the group field name, this function returns that custom name (i.e. what is displayed on the report). As mentioned in the note of the previous function, this is the opposite of how the GridRowColumnValue() function works.



Comments are closed.