MicroStrategy ONE

Populating the Report Grid

This example demonstrates populating the grid one row at a time by obtaining the WebGridRows collection.

Code sample

1. WebGridRows rows = reportGrid.getGridRows();
 

2. for (int i=0; i < rows.size(); i++){

3.   WebRow row = rows.get(i);

4.   WebHeaders rowElements = row.getHeaderElements();
 

5.   for (int j=0; j < rowElements.size(); j++){

6.     WebHeader rowElement = rowElements.get(j);
 

7.     int rowSpan = rowElement.getRowSpan();

8.     int semantics = rowElement.getSemantics();

9.     WebElement element = rowElement.getWebElement();
 

// using the properties of the header element, generate the HTML to display the grid.

…HTML code…
 

10.   }
 

11.  for (int j=0; j < row.size(); j++){

12.    WebRowValue WebRowValue = row.get(j);

13.    String cssClass = WebRowValue.getCssClass();

14.    String value = WebRowValue.getValue();
 

15.    if (WebRowValue.getType() == 1){ //metric
 

// HTML code to display the metric value

 

16.   }else{  //subtotal
 

// HTML code to display the subtotal value
 

17.  }

18. }

19.}

Explanation

Line 1 retrieves the WebGridRows object from WebReportGrid. Line 2 iterates through each row to get the WebHeaders and the row values. Lines 3-10 display the WebHeaders after obtaining all the properties for the header element. Line 11 displays the row values. Line 15 checks for the type, and depending on the value (metric or subtotal), uses the correct HTML to display the values.