Home
Analytics
how to remove hyperlink if data value is zero
venkatmadh
hi i am facing a problem,i.e how to remove hyperlink when data value is zero, i am attaching image please lookat it once......give me some suggestion on it.
Thanks
Find more posts tagged with
Comments
kclark
In the onCreate() of that datarow you could check for the value doing something like<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if(this.value == "0") {
// Change it to whatever you want here
this.value = "ZERO";
}
</pre>
bgbaird
You could also drop 2 data elements in the cell:
display the data in both of them, have the hyperlink in one of them and not the other
then hide/show based on the data value.
johnw
You can set your hyperlink. In the data elements/labels onRender event, you would set this.action = null;<br />
<br />
Take a look at the attached example. in it, I remove the hyperlink on the top if the output format is PDF, and in the table I am removing the hyperlink if the value is divisible by 2.<br />
<br />
(sorry, had to cut and paste the XML design, I can't attach for some reason)<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.23" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 3.7.2.v20120213 Build <3.7.2.v20120214-1408></property>
<property name="units">in</property>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="layoutPreference">auto layout</property>
<property name="bidiLayoutOrientation">ltr</property>
<data-sources>
<script-data-source name="Data Source" id="8"/>
</data-sources>
<data-sets>
<script-data-set name="Data Set" id="9">
<list-property name="resultSetHints">
<structure>
<property name="position">0</property>
<property name="name">number</property>
<property name="dataType">integer</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">number</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">number</property>
<property name="dataType">integer</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<method name="open"><![CDATA[x = 0;]]></method>
<method name="fetch"><![CDATA[if (x < 10)
{
row["number"] = x;
x++;
return (true);
}
else
{
return (false);
}]]></method>
</script-data-set>
</data-sets>
<styles>
<style name="report" id="4">
<property name="fontFamily">"Verdana"</property>
<property name="fontSize">10pt</property>
</style>
<style name="crosstab-cell" id="5">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="crosstab" id="6">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<property name="topMargin">0.25in</property>
<property name="leftMargin">0.25in</property>
<property name="bottomMargin">0.25in</property>
<property name="rightMargin">0.25in</property>
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<label id="7">
<property name="newHandlerOnEachEvent">true</property>
<method name="onRender"><![CDATA[if (reportContext.getOutputFormat().equalsIgnoreCase("PDF"))
{
this.setAction(null);
}
]]></method>
<text-property name="text">Test</text-property>
<list-property name="action">
<structure>
<property name="linkType">hyperlink</property>
<expression name="uri">"http://www.google.com"</expression>
<property name="targetWindow">_blank</property>
</structure>
</list-property>
</label>
<table id="10">
<property name="dataSet">Data Set</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">number</property>
<text-property name="displayName">number</text-property>
<expression name="expression" type="javascript">dataSetRow["number"]</expression>
<property name="dataType">integer</property>
</structure>
</list-property>
<column id="19"/>
<header>
<row id="11">
<cell id="12">
<label id="13">
<text-property name="text">number</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="14">
<cell id="15">
<data id="16">
<method name="onRender"><![CDATA[if (this.getValue() % 2 == 0)
{
this.action = null;
}
]]></method>
<property name="resultSetColumn">number</property>
<list-property name="action">
<structure>
<property name="linkType">hyperlink</property>
<expression name="uri" type="constant">http://www.google.com</expression>
<property name="targetWindow">_blank</property>
</structure>
</list-property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="17">
<cell id="18"/>
</row>
</footer>
</table>
</body>
</report>
</pre>
johnw
You can set your hyperlink. In the data elements/labels onRender event, you would set this.action = null;<br />
<br />
Take a look at the attached example. in it, I remove the hyperlink on the top if the output format is PDF, and in the table I am removing the hyperlink if the value is divisible by 2.<br />
<br />
(sorry, had to cut and paste the XML design, I can't attach for some reason)<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.23" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 3.7.2.v20120213 Build <3.7.2.v20120214-1408></property>
<property name="units">in</property>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="layoutPreference">auto layout</property>
<property name="bidiLayoutOrientation">ltr</property>
<data-sources>
<script-data-source name="Data Source" id="8"/>
</data-sources>
<data-sets>
<script-data-set name="Data Set" id="9">
<list-property name="resultSetHints">
<structure>
<property name="position">0</property>
<property name="name">number</property>
<property name="dataType">integer</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">number</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">number</property>
<property name="dataType">integer</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<method name="open"><![CDATA[x = 0;]]></method>
<method name="fetch"><![CDATA[if (x < 10)
{
row["number"] = x;
x++;
return (true);
}
else
{
return (false);
}]]></method>
</script-data-set>
</data-sets>
<styles>
<style name="report" id="4">
<property name="fontFamily">"Verdana"</property>
<property name="fontSize">10pt</property>
</style>
<style name="crosstab-cell" id="5">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="crosstab" id="6">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<property name="topMargin">0.25in</property>
<property name="leftMargin">0.25in</property>
<property name="bottomMargin">0.25in</property>
<property name="rightMargin">0.25in</property>
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<label id="7">
<property name="newHandlerOnEachEvent">true</property>
<method name="onRender"><![CDATA[if (reportContext.getOutputFormat().equalsIgnoreCase("PDF"))
{
this.setAction(null);
}
]]></method>
<text-property name="text">Test</text-property>
<list-property name="action">
<structure>
<property name="linkType">hyperlink</property>
<expression name="uri">"http://www.google.com"</expression>
<property name="targetWindow">_blank</property>
</structure>
</list-property>
</label>
<table id="10">
<property name="dataSet">Data Set</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">number</property>
<text-property name="displayName">number</text-property>
<expression name="expression" type="javascript">dataSetRow["number"]</expression>
<property name="dataType">integer</property>
</structure>
</list-property>
<column id="19"/>
<header>
<row id="11">
<cell id="12">
<label id="13">
<text-property name="text">number</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="14">
<cell id="15">
<data id="16">
<method name="onRender"><![CDATA[if (this.getValue() % 2 == 0)
{
this.action = null;
}
]]></method>
<property name="resultSetColumn">number</property>
<list-property name="action">
<structure>
<property name="linkType">hyperlink</property>
<expression name="uri" type="constant">http://www.google.com</expression>
<property name="targetWindow">_blank</property>
</structure>
</list-property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="17">
<cell id="18"/>
</row>
</footer>
</table>
</body>
</report>
</pre>
venkatmadh
<blockquote class='ipsBlockquote' data-author="'johnw'" data-cid="111585" data-time="1353016612" data-date="15 November 2012 - 02:56 PM"><p>
You can set your hyperlink. In the data elements/labels onRender event, you would set this.action = null;<br />
<br />
Take a look at the attached example. in it, I remove the hyperlink on the top if the output format is PDF, and in the table I am removing the hyperlink if the value is divisible by 2.<br />
<br />
(sorry, had to cut and paste the XML design, I can't attach for some reason)<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.23" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 3.7.2.v20120213 Build <3.7.2.v20120214-1408></property>
<property name="units">in</property>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="layoutPreference">auto layout</property>
<property name="bidiLayoutOrientation">ltr</property>
<data-sources>
<script-data-source name="Data Source" id="8"/>
</data-sources>
<data-sets>
<script-data-set name="Data Set" id="9">
<list-property name="resultSetHints">
<structure>
<property name="position">0</property>
<property name="name">number</property>
<property name="dataType">integer</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">number</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">number</property>
<property name="dataType">integer</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<method name="open"><![CDATA[x = 0;]]></method>
<method name="fetch"><![CDATA[if (x < 10)
{
row["number"] = x;
x++;
return (true);
}
else
{
return (false);
}]]></method>
</script-data-set>
</data-sets>
<styles>
<style name="report" id="4">
<property name="fontFamily">"Verdana"</property>
<property name="fontSize">10pt</property>
</style>
<style name="crosstab-cell" id="5">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="crosstab" id="6">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<property name="topMargin">0.25in</property>
<property name="leftMargin">0.25in</property>
<property name="bottomMargin">0.25in</property>
<property name="rightMargin">0.25in</property>
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<label id="7">
<property name="newHandlerOnEachEvent">true</property>
<method name="onRender"><![CDATA[if (reportContext.getOutputFormat().equalsIgnoreCase("PDF"))
{
this.setAction(null);
}
]]></method>
<text-property name="text">Test</text-property>
<list-property name="action">
<structure>
<property name="linkType">hyperlink</property>
<expression name="uri">"http://www.google.com"</expression>
<property name="targetWindow">_blank</property>
</structure>
</list-property>
</label>
<table id="10">
<property name="dataSet">Data Set</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">number</property>
<text-property name="displayName">number</text-property>
<expression name="exp<b></b>ression" type="javascript">dataSetRow["number"]</expression>
<property name="dataType">integer</property>
</structure>
</list-property>
<column id="19"/>
<header>
<row id="11">
<cell id="12">
<label id="13">
<text-property name="text">number</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="14">
<cell id="15">
<data id="16">
<method name="onRender"><![CDATA[if (this.getValue() % 2 == 0)
{
this.action = null;
}
]]></method>
<property name="resultSetColumn">number</property>
<list-property name="action">
<structure>
<property name="linkType">hyperlink</property>
<expression name="uri" type="constant">http://www.google.com</expression>
<property name="targetWindow">_blank</property>
</structure>
</list-property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="17">
<cell id="18"/>
</row>
</footer>
</table>
</body>
</report>
</pre></p></blockquote>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Thanks you very much for quick responce