Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
How to format a string in Data Binding
xenotel
I have a integer value from my database that is a serialized number like 20130000001 and I have a requirement to reformat the string like 2013-0000001.<br />
<br />
I tried to call the BirtStr function from the Data Binding dialog and it throws an java exception during rendering.<br />
<br />
This is what I have in the Data Binding Expression Builder:<br />
<br />
<strong class='bbc'> BirtStr.left(dataSetRow["JobWrit::JobSummary::number"],4)</strong><br />
<br />
I do not seem to know where I can call string functions at in BIRT. By the way I am running BIRT Framework 3.7.2 in Eclipse Indigo
Find more posts tagged with
Comments
kclark
You could use something like this<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var test = "201200000001";
this.text = test.substr(0, 4) + "-" + test.substr(4);</pre>
xenotel
Thanks!<br />
<br />
I could get your example to work but when I tried:<br />
<br />
var test = row["JobWrit::JobSummary::number"];<br />
this.text = test.substr(0, 4) + "-" + test.substr(4);<br />
<br />
I get the following errors:<br />
<br />
<p class='bbc_indent' style='margin-left: 40px;'>the following items have errors:<br />
<br />
ReportDesign (id = 1):<br />
+ There are errors evaluating script "var test = dataSetRow["JobWrit::JobSummary::number"];<br />
this.text = test.substr(0, 4) + "-" + test.substr(4);":<br />
ReferenceError: "dataSetRow" is not defined. (<inline>#1) (Element ID:1)<br /></p>
<br />
I assumed I could reference a Column Binding but it doesnt seem to work.<br />
<br />
I also tried to use VALUE-OF formatting like so:<br />
<br />
<VALUE-OF>row["JobWrit::JobSummary::number"]</VALUE-OF><br />
<br />
and all I get printed is the literal of the above like:<br />
<br />
<VALUE-OF>row["JobWrit::JobSummary::number"]</VALUE-OF><br />
<br />
<br />
I dont see to know how to get the javascript to evaluate correctly.
kclark
Can you post your rptdesign?
xenotel
<blockquote class='ipsBlockquote' data-author="'kclark'" data-cid="117817" data-time="1371771855" data-date="20 June 2013 - 04:44 PM"><p>
Can you post your rptdesign?<br /></p></blockquote>
<br />
<br />
I attached the designer file for you. I did strip out the user/password from the data even though it was encrypted. :ph34r: