Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Highlighting a text within a row
vinod
Hi
i have a report parameter (say params["job"].value) in my design.i am fetching one column(say dataSetRow["Content"]) from the database.Now what I am trying to do is to highlight that report parameter value(for ex Engineer) within a row in the report design.So only Engineer is to be highlighted in all the rows fetched by dataSetRow["Content"] .I have seen from the examples that based on conditional highlighting selective rows can be highlighted in the design,but my requirement is to highlight a text(which is the value of the report parameter) within a row in the report and not the entire row.
In Oncreate Method of the table row in design , i am trying to do
row = this.getRowData().getColumnValue("Content");
parameter = params["job"].value.toLowerCase();
var intIndexOfMatch = row .indexOf(parameter);
while (intIndexOfMatch !=-1)
{
// Code for colourind the matched string background
// Get the index of any next matching substring.
intIndexOfMatch = row .indexOf(parameter);
}
Can someone please guide me,please
Find more posts tagged with
Comments
bhanley
I have attached a sample to do what you are looking for. It is simpler than the strategy you were driving at and does not involve modifying the table/source data at all. Instead, I used a Text control to render a column on the table (instead of a standard Data Item). In the Text Item, I use a Regular Expression to find the term passed into the report via the parameter and I re-write the field to show that term in BOLD.<br />
<br />
This is the important bit:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
// Build a RegExp (need a stand-alone variable param interpolation)
regExp = new RegExp (params["pHLText"].value, "gi");
//Scrub the data.
row["PRODUCTDESCRIPTION"].replace(regExp, "[b]" + params["pHLText"].value + "[/b]")
</pre>
<br />
Notice the RegExp is set to be case insensitive and global in its scope.<br />
<br />
The sample is built using the bundled Classic Models database so you should be able to download and run it your self.<br />
<br />
Good Luck!
bhanley
The sample I added to DevShare is updated for a little more robust formatting for the target string.<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/devshare/birt-report-designers/859-conditional-text-formatting/'>Conditional
Text Formatting - Tips & Tricks - BIRT Exchange</a>
vinod
Thanks bhanley this was exactly i was looking for.Just i changed the bold tag to span tag for colouring the keyword:-).Thanks once again.
TheRealDea
Is it possible to use this index method or some other to iterate the columns per a row, in order to compile the column-name and column-value into a string?<br />
<br />
something like row
.name or row
.value<br />
<br />
Ideally, I would be looking to the OnFetch/script method of the dataset to be the container of this piece of javascript.<br />
<br />
Thanks,