Home
Intelligence (Analytics)
Internal hyperlink with decimals
Ingo
Hi.<br />
<br />
I'm just facing a curious problem when working with hyperlinks to an internal bookmark. I cannot prevent that a thousand seperator is inserted in the link. For example for the decimal number <pre class='_prettyXprint _lang-auto _linenums:0'>1782</pre> the generated link is <pre class='_prettyXprint _lang-auto _linenums:0'>#1.782</pre>. But this seperator is not inserted when bookmarking this number. Thus obviously the link does not work. The only solution I found so far is to provide an additional field where the number is converted to a string (in sql) and use this field for the link...<br />
<br />
When I use the same number for a drill-through link everything works fine. No thousand seperators.<br />
<br />
How can I prevent the thousand seperator being inserted for an internal link?!<br />
<br />
Thanks,<br />
Ingo<br />
<br />
BTW.: I'm using Birt 2.6.1
Find more posts tagged with
Comments
mwilliams
When you make your internal bookmark hyperlink, if you change the "linked expression" to row["yourField"].toString() does that help?
Ingo
Simple and effective! Great thanks, as always!
But still, this behaviour is not desired or is it?
Thanks,
Ingo
mwilliams
You're very welcome. I don't know if it's necessarily desired or not. Integer fields work as expected without changing them to a string. It seems that floats and decimal types must be converted to strings. You could always log a bug for this and they'd probably tell you why this is done if you pose the question in your post, but it doesn't seem like too big of a deal to change to a string before linking. Let me know if you run into any issues with this. Or if you post a bug and get a response to why, go ahead and post that info in here if you don't mind.
Ingo
You are absolutely right. It's not that big a deal. At least we all know that behaviour now...
I think it's a bit inconsistent since the bookmark value is not getting a thousand seperator...I will log a bug and keep you posted...
mwilliams
Is that causing you an issue? Or are you just seeing inconsistency that still works?
Ingo
No, I'm okay with that. But as I said before, I think that it might confuse the users. For example when you use internal bookmarking in a pdf you don't even see why the link does not work...
When you know this "issue" it's not a problem at all.
mwilliams
Oh, so the bookmark that you see in PDF is not get a comma in the bookmarks to the left, but it does show in the report? Is that what you mean? Sorry if I'm being dumb in my confusion.
Ingo
Hmm...maybe I'm didn't make myself clear enough. Or I'm doing it all wrong.
To reconstruct the issue. Take a query that results in a table with a column of numbers, e.g. row["id"]. I display this table twice in the report. The first is used to create links (Bookmark: row["ID"], Linked Expression: row["ID"]), on the second one I use bookmark with the expression row["ID"]. I don't do any number formatting or something like that, so that both tables simply show the number without any thousand seperators. Now, when I render the report as PDF I can click on the number in the first table (shown as links, which is correct, with no seperator) but nothing happens (since the bookmark do not have a thousand seperator). And I don't see bookmarks in the TOC...
Hopes that clarifies the issue. Again, it's not a problem to use toString() but how should you know this in the first place? Or am I doing it all wrong?!
mwilliams
Ingo,
Ok, gotcha. I did this earlier with just a column of integers and it worked fine. It only didn't work when I used type "float" or "decimal". So, I'm guessing there is a reason that these need to be converted in most cases. Possibly because of a possible "cents" amount, I don't know what the reason for that would be. There are expression builders for both the bookmark and the hyperlink, so you should be able to guarantee that they're the same by writing the same expression. Besides just row["fieldName"], since that's not working. Could use script to remove the punctuation, is what I'm meaning.
Ingo
Hi again...<br />
<br />
I did a query to an oracle database thus the resulting columns were always decimal even when they were configured as integer (== number(38,0))...<br />
<br />
But, I just did a simple test if it would work with integer or float via a scripted ds. It does not work for any datatype. For all datatypes the link is like this one: <pre class='_prettyXprint _lang-auto _linenums:0'><a href="#2.000">2000</a></pre>
<br />
<br />
You can find the report (I had to zip it because uploading the rptdesign file had failed) and the resulting html (to see the links in the source)<br />
<br />
Hope I did everything correctly.
mwilliams
So the .toString() thing didn't work?
Ingo
No no no. Sorry, I think I'm still confusing you... It all worked perfectly. Thanks again. The example showed only the problem I had, that internal hyperlinks do not work with numbers (float, integer, decimal) without modifying the link expression...
mwilliams
Ha ha... Ok. I thought you ran into an issue. Sorry. I didn't have a problem with the hyperlink when I used integer. That being said, I used a field that only had 3 digits and wouldn't have ran into any punctuation. I'll have to try that and see if I have the same issue. Let me know if you run into any issues using the solution we found that work, and as always, let us know whenever you have BIRT questions!