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)
Wraping runningcount in Birt Report
myusuf
<p>Hi guys,</p>
<p> </p>
<p>I have a simple requirement. I have a Serial Number Column in a Report. For this Sl.No. I have used the Aggregation function Runningcount. Now the issue is, whenever the records fetched is huge, the serial number is not displayed completely in the report. It is getting truncated.</p>
<p> </p>
<p>So, can any one tell me how to wrap the Serial Number Content in this scenario, so that i can have fixed column width in the report.</p>
<p> </p>
<p>Attched is the sample report design file
Find more posts tagged with
Comments
Matthew L.
<p>Using your original example, here is how I would accomplish this task.</p>
<p>First I would set the aggregation "S.No" in the table binding instead of an aggregation element. This is necessary as the aggregation element is a number type instead of a String type.</p>
<p>Then I added a data element of String Type where your existing S.No aggregation element was located.</p>
<p>The data element uses the table binding "S.No" to get its counter, however I wrapped the data value with a JavaScript function (See code block) to hard-wrap the text.</p>
<p>The JavaScript function is located in the initialize method so that it can be called almost anywhere within the report design.</p>
<p> </p>
<p>The end result is a hard-wrapped value based on the number of characters you specify in the function call.</p>
<pre class="_prettyXprint _lang-js">
//
// This function is placed in the reports initialize method
// Hard wrap long string by number of characters
//
function hardWrap(longStr, chrWidth){ //function call: hardWrap(inputString, widthDesired)
longStr = "" + longStr;
if (longStr) { //if longStr is not null
strLen = longStr.length; //get length of longStr
if(strLen <= chrWidth) //if longStr is shorter than character width desired then...
return longStr; //TRUE: return the original input string
return (longStr.substring(0, chrWidth) + "\u200B" + hardWrap(longStr.substring(chrWidth, strLen), chrWidth)); //FALSE: return modified string (\u200B = Zero Width Space, can also use \n)
} //endif
} //end function
//
</pre>
myusuf
<p>Thanx <strong><span style="color:rgb(0,0,0);"><span style="font-family:arial, sans-serif;"><span style="font-size:10pt;">Matthew..!! This method solved my </span></span></span></strong><strong><span style="color:rgb(0,0,0);"><span style="font-family:arial, sans-serif;"><span style="font-size:10pt;">case.
</span></span></span></strong><strong><span style="color:rgb(0,0,0);"><span style="font-family:arial, sans-serif;"><span style="font-size:10pt;">
</span></span></span></strong><strong><span style="color:rgb(0,0,0);"><span style="font-family:arial, sans-serif;"><span style="font-size:10pt;"> </span></span></span></strong></p>