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)
Scripted Data Source - Basic
afv
Hallo, i am new to BIRT.
I would like to create a Scripted Data Set, with the possibility to populate afterwards the DS. I could find a lot of examples, that's not the problem, but trying to do this basic example i don't get any values into the ds. whats wrong?
Could you please help in this case? Thank you.
1. Scripted Data Source and Data Set have been created.
2. In the "fetch" Event of the Dataset i write this small code part: (just to test)
row["firstname"] = "111111";
row["secondname"] = "123";
row["age"] = "1234";
return false;
3. I expect now that in the Data Set i have 1 row with the coded strings in the 3 columns.
--> no data will be displayed, dataset remains empty
What is wrong? DataSet has no data after running the report.
Thank you for any help.
Find more posts tagged with
Comments
kclark
Can you post your rptdesign for me to look at?
Yaytay
<blockquote class='ipsBlockquote' data-author="'afv'" data-cid="110096" data-time="1349276704" data-date="03 October 2012 - 08:05 AM"><p>
2. In the "fetch" Event of the Dataset i write this small code part: (just to test)<br />
<br />
row["firstname"] = "111111";<br />
row["secondname"] = "123";<br />
row["age"] = "1234";<br />
<br />
return false;<br />
<br /></p></blockquote>
If you return false you don't add anything to the result set.<br />
To achieve what you want you need to return true the first time the function is called, and return false on subsequent calls.<br />
<br />
The problem I always have with achieving that is that it needs a variable with a context that is larger than the fetch method, in order to keep track of fetch being called.<br />
I usually end up with something like:<br />
Report.initialize:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var primaryId = 0;
</pre>
DataSet.fetch:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if( primaryId < 1000 ) {
row[ 'Id' ] = primaryId;
row[ 'Column1' ] = 'Value:' + Math.random();
row[ 'Column2' ] = 'Value:' + Math.random();
row[ 'Column3' ] = 'Value:' + Math.random();
primaryId = primaryId + 1;
return true;
}
return false;
</pre>
afv
Thank you for the reply.... Yes, indeed now it seems very perfect for me...
It works fine.