MicroStrategy ONE
ReportGridCellColTitleImpl
ReportGridCellColTitleImpl is a subclass of AbstractReportGridDisplayCell which is responsible for displaying the contents in the cells of a column 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 CustomReportGridCellColTitleImpl.
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: ReportMyCellCollTitleImpl
* Description: Represents a Column title cell in a report grid
* Copyright: Copyright (c) 2006
* Company: MicroStrategy
*
*/
public class CustomReportGridCellColTitleImpl extends ReportGridCellColTitleImpl {
/**
* Default constructor for the class
**/
public CustomReportGridCellColTitleImpl () {
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 column 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 colTitle = 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) {
colTitle = "<B>Metrics</B><IMG SRC='metric.jpg'/>";
} else if (unit.getUnitType() == EnumDSSXMLTemplateUnitType.DssXmlTemplateAttribute) {
//Create a link for all row titles.
colTitle = "<A HREF='" + colTitle + ".htm' >" + colTitle + "</A>";
} else {
colTitle ="other: " + colTitle;
}
// Render the contents that were set
// in the previous lines of code.
mo.append(colTitle);
} 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