MicroStrategy ONE

ReportGridCellMetricValueImpl

ReportGridCellMetricValueImpl is a subclass of AbstractReportGridDisplayCell which is responsible for displaying the contents in the cells for metric values of a report grid.

The following code sample shows how you can extend this class and generate customized content such as highlighting the displayed content based on specific values. The new custom class is called CustomReportGridCellMetricValueImpl.

Code Sample

package com.microstrategy.web.app.transforms;

import com.microstrategy.web.app.utils.HTMLHelper;

import com.microstrategy.web.beans.MarkupOutput;

import com.microstrategy.webapi.EnumDSSXMLBaseFormType;

import com.microstrategy.web.objects.WebRowValue;

import com.microstrategy.web.tags.ImageTag;

import com.microstrategy.web.tags.TagsFactory;

/**

 * Title: Transform Component: CustomReportGridCellMetricValueImpl

 * Description: Represents a metric value cell in report grid

 * Copyright: Copyright (c) 2006

 * Company: MicroStrategy

 *

 */

public class CustomReportGridCellMetricValueImpl extends ReportGridCellMetricValueImpl {

 

public CustomReportGridCellMetricValueImpl() {

super();

}

 

//This method adds an HTML tag before the cell content

public void generatePreContent(MarkupOutput mo) {

super.generatePreContent(mo) ;

mo.append("<B>");

}

 

// This method appends an HTML tag after the cell content

public void generatePostContent(MarkupOutput mo) {

mo.append("</B> <BR/><A href='http://www.microstrategy.com'>MSTR</A>");

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 metric value cells. 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"

 * tranform parameter to 'false'.

 * Refer to the Transform Parameters Reference in MSDL.

 **/

public void generateText(MarkupOutput mo) {

 

WebRowValue rowValue = getWebRowValue();

String metricValue = getText();

if (rowValue != null) {

String spanPrefix = "";

String spanPostfix = "";

switch (rowValue.getSemantics()) {

case EnumDSSXMLBaseFormType.DssXmlBaseFormPicture:

//For threshold images

case EnumDSSXMLBaseFormType.DssXmlBaseFormUrl:

ImageTag imgTag = TagsFactory.getInstance().newImageTag();

imgTag.setSrc(rowValue.getValue());

imgTag.render(mo);

break;

 

case EnumDSSXMLBaseFormType.DssXmlBaseFormSymbol:

//For threshold quick symbols

//generateThresholdSymbol(mo, Integer.parseInt(rowValue.getValue()));

break;

 

case EnumDSSXMLBaseFormType.DssXmlBaseFormHTMLTag:

mo.append(HTMLHelper.decode(rowValue.getValue()));

break;

 

default:

// Customize this portion by adding conditions

// to display content of your choice.

// This condition highlights the content

// based on specific values.

if (getWebRowValue().getCcl().length() > 0) {

spanPrefix = "<SPAN STYLE=\"COLOR: #" + HTMLHelper.convertColorBGRtoRGB(HTMLHelper.convertColorDecimalToHex(getWebRowValue().getCcl())) + "\" >";

spanPostfix = "</SPAN>";

}

 

//Highlight the value if equals to 176

if (metricValue.equals("176%")) {

mo.append(spanPrefix + "<I>"+ metricValue + "</I>" + spanPostfix);

} else {

mo.append(spanPrefix + metricValue + spanPostfix);

}

}

 

} else {

mo.append(metricValue);

}

}

}

See also