MicroStrategy ONE
ReportGridCellRowTitleImpl
ReportGridCellRowTitleImpl is a subclass of AbstractReportGridDisplayCell which is responsible for displaying the contents in the cells of a row title of a report grid.
The following code sample shows how you can extend this class and generate customized content such as adding your own tool tip. The new custom class is called CustomReportGridCellRowTitleImpl.
Code Sample
package com.microstrategy.web.app.transforms;
import com.microstrategy.web.beans.MarkupOutput;
import com.microstrategy.web.objects.WebObjectsException;
import com.microstrategy.web.objects.WebTemplateUnit;
import com.microstrategy.web.objects.WebTitle;
import com.microstrategy.webapi.EnumDSSXMLTemplateUnitType;
/**
* Title: Transform Component: CustomReportGridCellRowTitleImpl
* Description: Represents a Row Header cell in report grid
* Copyright: Copyright (c) 2006
* Company: MicroStrategy
*
*/
public class CustomReportGridCellRowTitleImpl extends ReportGridCellRowTitleImpl {
/**
* Default constructor for the class
**/
public CustomReportGridCellRowTitleImpl() {
super();
}
//This method adds an HTML tag before the cell content
public void generatePreContent(MarkupOutput mo) {
super.generatePreContent(mo);
mo.append("<I>") ;
}
/**
* Generate the post-contents of the cell
* @param mo the MarkupOutput object
**/
// This method appends an HTML tag after the cell content
public void generatePostContent(MarkupOutput mo) {
mo.append("</I>");
super.generatePostContent(mo);
}
/**
* Generate the text contents of the cell
* @param mo the MarkupOutput object
*
* This method can be overwritten to modify the contents
* of the row title. You can render images, hyperlinks,
* and so on based on the unit type, the attribute name,
* and other conditions.
*
* The getText() method is called inside the generateContent()
* method which also renders 'drill' hyperlinks.
* To avoid showing these links and create different
* hyperlinks instead, initialize the "showDrillHyperlink"
* transform parameter to 'false'.
* Refer to the Transform Parameters Reference in MSDL.
**/
public void generateText(MarkupOutput mo) {
try {
//Get the title
String rowTitle = getText();
//getWebTitle is defined in ReportCellRowTitleImpl
WebTitle title = getWebTitle();
WebTemplateUnit unit = title.getWebTemplateUnit();
// Based on the unit type, set the text to be displayed
// as the content of the cell
if (unit.getUnitType() == EnumDSSXMLTemplateUnitType.DssXmlTemplateMetrics) {
rowTitle = "<B>Metrics</B><IMG SRC='metric.jpg'/>";
} else if (unit.getUnitType() == EnumDSSXMLTemplateUnitType.DssXmlTemplateAttribute) {
//Create a link for all row titles.
rowTitle = "<A HREF='" + rowTitle + ".htm' >" + rowTitle + "</A>";
} else {
rowTitle ="other: " + rowTitle;
}
// Render the contents that were set
// in the previous lines of code.
mo.append(rowTitle);
} catch (WebObjectsException woe){
//The Template Unit was not available, ignore the error
return;
}
}
/**
* Return the tool tip content for this cell.
* When this method is not overwritten,
* the abstract class generates the
* appropriate tooltip for headers and titles
*/
protected String generateTooltipContent() {
return "my own tool tip";
}
}
See also
-
Customizing Cell Rendering Classes: Using Custom Cell Rendering Classes
-
References: API Reference