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 access a DataSet within a script?
s_shetty
Hi Everybody,
I have a requirement in my application where in I need a script to be executed on creation of each cell in a table.The table is binded to a DataSet & I want to access the data of that particular cell in my script. Can someone please tell me how to access the DataSet in a script?
Thanks & Regards,
Shreya
Find more posts tagged with
Comments
Megha Nidhi Dahal
Hello Shreya,
I'm not clear what exactly is your requirement, but, if you want to run a script for every row in that table or alternatively for every cell in that row you could do it, I have attached screen shots of what I mean.
Hope this helps.
regards
Arpan
s_shetty
Hi Arpan,
Thanks for the response. I had already tried this approach but it had resulted in the following exception :
org.eclipse.birt.report.engine.api.EngineException: Unhandled exception when executing script.
I am quite new to BIRT,so I am not familiar with all the concepts. I have created a sample report using the sample DataBase so that I can explain my requirement clearly.
In the following report , I have a table which consists of 3 columns. The DataSet columns CONTACTFIRSTNAME & CONTACTLASTNAME are concatenated to form a single column CONTACT in the table. I want to create a hyperlink on the data in every cell of the column CONTACT. Also I want to retrieve the values CONTACTFIRSTNAME & CONTACTLASTNAME for that particular cell and append it to the URL. I tried accessing the DataSet with inputparams["column_name"] but it doesn't work. Could you please tell me what's the correct way of accessing the DataSet within a script?
Regards,
Shreya
johnw
Create a new binding on your table called FullName. The expression will be:
row["CONTACTFIRSTNAME"] + " " + row["CONTACTLASTNAME"];
Now, you can reference the FullName with row["FullName"].
Create a new hyperlink on one of your data fields (located under the Properties tab, under Hyperlink), and set the expression to "
http://myTargetURl/whatever?value="
; + row["FullName"];
that should work for you. You can reference fields in the table binding using "row["fieldName"]", or reference the parent data set with "dataSetRow["fieldName"]"
I have attached an example.
John
s_shetty
Hi John,
Thanks for the response. I tried the method suggested by you but I am still facing the same problem. If I specify the link within the double quotes as done by you in the sample report, the URL created is relative to the container i.e it is created as follows:
'
http://localhost/Reports/"http://google.com?\""
; + row["FullName"] "\"" '.
Whereas if I specify the link without the double quotes, the URL is created properly but still the actual value of the field 'row["FullName"]' is not fetched . Instead the URL would be as follows:
'
http://google.com?row["FullName"]
'
Can you please tell me if I am missing something?
Regards,
Shreya
Megha Nidhi Dahal
Hello Shreya,
Even I'm quite new to BIRT. Though it may not the best of approach, but I would have done something like:
1) Instead of column binding, I would have used a dynamic text in the detail.
2) I would have set the content type of the text to be HTML
3) Then I would have done something like this:
var contactName = row["CONTACTFIRSTNAME"]+" "+row["CONTACTLASTNAME"];
"<a href=\"
http://google.com?"+contactName+"\">"+contactName+"</a>"
;
I tried it and is working.
Hope this helps, PFA the designer.
regards
Arpan
johnw
In the Hyperlink dialog, make sure you have URI selected. The expression needs to be set exactly as I entered it. <br />
<br />
By the way, what version of BIRT are you using?<br />
<br />
John<br />
<br />
<blockquote class='ipsBlockquote' data-author="'s_shetty'" data-cid="66704" data-time="1280124848" data-date="25 July 2010 - 11:14 PM"><p>
Hi John,<br />
<br />
Thanks for the response. I tried the method suggested by you but I am still facing the same problem. If I specify the link within the double quotes as done by you in the sample report, the URL created is relative to the container i.e it is created as follows:<br />
<br />
'<a class='bbc_url' href='
http://localhost/Reports/"http://google.com?\"'>http://localhost/Reports/"http://google.com?\""</a>
; + row["FullName"] "\"" '.<br />
<br />
Whereas if I specify the link without the double quotes, the URL is created properly but still the actual value of the field 'row["FullName"]' is not fetched . Instead the URL would be as follows:<br />
<br />
' <a class='bbc_url' href='
http://google.com?row'>http://google.com?row</a>["FullName"]
'<br />
<br />
<br />
Can you please tell me if I am missing something?<br />
<br />
Regards,<br />
Shreya<br /></p></blockquote>