Home
Analytics
properCase in Birt
ngan.dk@gmail.com
<p>Hi everyone,</p>
<p> </p>
<p>I convert my report from Crystal to birt. The report take a text field user input and and compare then return data that at least matching the string. I want to ignore case sensitive, so in Crytal report, there is ProperCase function.:</p>
<p>{Command.colume_name} like '*' + ProperCase(?input_parameter) + '*'. But I cannot find equivalent ProperCase in birt. There are BirtStr.toLower() and BirtStr.toUpper() only.</p>
<p> </p>
<p>Since I don't want toLower or toUpper because my database has both lower case, upper case and mix case</p>
<p> </p>
<p>Is there a way or a script that can solve the ProperCase issue?</p>
<p> </p>
<p>Thank you in advance</p>
Find more posts tagged with
Comments
JFreeman
<p>What version of BIRT are you using?</p>
<p>What type of data base are you querying?</p>
<p>Are you using a JDBC connection?</p>
<p> </p>
<p>You may be able to do this within the SQL query depending on your data base and JDBC driver.</p>
<p> </p>
<p>Alternatively, you could also use a JavaScript function to convert the string to TitleCase.</p>
<p>For example:</p>
<pre class="_prettyXprint _lang-js">
function toProperCase(str)
{
var noCaps = ['of','a','the','and','an','am','or','nor','but','is','if','then', 'else','when','at','from','by','on','off','for','in','out','to','into','with'];
return str.replace(/\w\S*/g, function(txt, offset){
if(offset != 0 && noCaps.indexOf(txt.toLowerCase()) != -1){
return txt.toLowerCase();
}
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
</pre>
ngan.dk@gmail.com
<p>Thank you for your answer.</p>
<p> </p>
<p>I found a way to fix the problem is to apply BirtStr.to_lower(columne_name) like BirtStr.to_lower(input_param) in the filter</p>
<p> </p>
<p>So this way, it does not care if user input MIX or mix or MiX, then it return MIX, mix, Mix, MiX or MiX...</p>
JFreeman
<p>I think I had misunderstood your requirement.</p>
<p>I had thought you need this for the query itself not for a filter.</p>
<p> </p>
<p>In the case of a filter, you solution of making those the column and the parameter lower case is a much simpler solution.</p>
<p>I'm glad that you got it figured out.</p>
<p> </p>
<p>Let us know if you have additional questions.</p>
ngan.dk@gmail.com
<p>Sorry for my confusing question. Thank you for you support. I definitely come back for more question
. I am have been learning Birt for 2 months. I really impress and like Birt. Birt report run very fast even with subreports and there are many more advance features. </p>
<p> </p>
<p>Thank you Birt Report Team and Jesse</p>