One common use of the Grid class is for rendering HTML tables containing analytics results.

The following JSP code snippet provides an example of this usage for our example two-dimensional grid.

This example assumes that the Region and Year are navigation dimensions, not properties (hence the use of the getDimVal method on the labels in the axes).

<%
// Get X and Y labels
Grid grid = new Grid(iterator,"TransCount","Region","Year");
List regions = grid.getLabels(0);
List years = grid.getLabels(1);

// Display header row
%><tr><td></td><%
for (int i=0; i<regions.size(); i++) {
  Label region = (Label)regions.get(i);
  %><td><%= region.getDimVal().getName() %></td><%
}
%></tr><%

// Display data rows
for (int i=0; i<years.size(); i++) {
  Label year = (Label)years.get(i);
  %><tr><td><%= year.getDimVal().getName() %></td><%
  for (int j=0; j<regions.size(); j++) {
    Label region = (Label)regions.get(j);
    Cell cell = grid.getValue(region, year);
    %><td><%= cell.getValue() %></td><%
  }
  %></tr><%
}
%>

which, for our example result set above, would render in the form:


Copyright © Legal Notices