MicroStrategy ONE

Populating the Grid with the Lower-level Objects

This example demonstrates how to get the lower-level objects from the WebReportGrid object and populate the grid. Start by getting the report titles to display the layout of the report.

Code sample

1. WebGridTitles rowTitles = reportGrid.getRowTitles();

2. WebGridTitles colTitles = reportGrid.getColumnTitles();

3. WebGridTitles pageTitles = reportGrid.getPageTitles();
 

4. int span;

5. int depth;

6. int hc;

7. int type;

8. int colTitleCount;

9. int position;

10. String name;

11. String class;
 

12. if (! rowTitles.isEmpty()){
 

13. colTitleCount = colTitles.size();

14. for (int i=0; i < rowTitles.size(); i++) {

15. WebTitle rowTitle = rowTitles.get(i);

16. span = rowTitle.getSpan();

17. depth = rowTitle.getDepth();

18. hc = rowTitle.getHeaderCount();

19. type = rowTitle.getType();

20. cssClass = rowTitle.getCssClass();
 

21. WebTemplateUnit wtu = rowTitle.getWebTemplateUnit();

22. position = wtu.getPosition();

23. name = wtu.getName();
 

24. if (type == 0 || type == 4){

25. WebSubTitles rowSubTitles = rowTitle.getGridSubTitles();

26. if (! rowSubTitles.isEmpty()){

27. for (int j=0; j < rowSubTitles.size(); j++){

28. WebSubTitle rowSubTitle = rowSubTitles.get(j);
 

29. int subtitleSpan = rowSubTitle.getSpan();

30. String name = rowSubTitle.getName();

 

//using the attributes for the title and subtitle, generate the HTML to display the grid

…HTML code…

 

31. WebObjectInfo woi = rowSubTitle.getTarget();

32. int objectType = woi.getType();

33. if (objectType == 12){ //attribute

34. WebAttribute attribute = (WebAttribute)woi;

35. else{ //attribute form

36. WebAttributeForm form = (WebAttributeForm)woi;

37. }

38. }

39. }

40. }

41. else{
 

// using the title properties, generate the HTML to display the grid.

…HTML code…
 

42. }

43. }

Explanation

Lines 1-3 get all the objects (row, column, and page titles) that are used. Line 12 starts populating the row tiles. Line 13 gets the count of column titles. Lines 14-20 display the individual title in the grid. Lines 21-23 get the position in the axis and the name for each row title from its template unit. Line 24 checks for type attribute (value 0) or dimension (value 4) to verify the presence of subtitles. If there are no subtotals, the grid should be populated. Lines 29-30 get the properties of the subtitle. The HTML for the grid can be generated using the title and subtitle attributes. Note that if there is a dimension in the template for the report, there will be multiple subtitles for a single subtitle. In such a case, consider using a while loop instead of a for loop. The subtitle can also be obtained from a WebObjectInfo object that can either be a WebAttribute or a WebAttributeForm. Line 32 determines the type of object.  Lines 41-43 generate the HTML for displaying the grid using the title properties.

The page titles and column titles can be obtained in a similar manner.