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)
Need to create dynamic number of images in masterpage header
anitaV
<p>Hi All,</p>
<p> </p>
<p>I need to create images in masterpage header section but number of images are not constant. They are depending on the values in dataset.</p>
<p> </p>
<p>Can you please help me on creating dynamic number of images in header?</p>
Find more posts tagged with
Comments
anitaV
<p>Any help will be appreciable, please help on this.</p>
Clement Wong
<p>Can you please provide an example of the use case?</p>
<p> </p>
<p>For example, you'll need to query # of customers and for those # of customers, you'll need to display each of their logos in the header?</p>
anitaV
<p>Hi Wong,</p>
<p> </p>
<p>First of all Thank a lot for the reply. Use case is as given.</p>
<p> </p>
<p>I am creating report for a requisition. For some requisition there can be 5 number of accession images and for some there can be 3 and for some of the requisitions there can be 0. I need to display the images as per the data, please help on how can we implement it.</p>
Clement Wong
<p>Sorry, I am not familiar with requisition reports and accession images so I don't know the specifics of formatting, etc...</p>
<p> </p>
<p>But I have created a sample report that reads a value from the database, and dynamically creates that # of images in the header of the master page. The magic happens in the <em>beforeFactory </em>event.</p>
anitaV
<p>Thanks Wong...</p>
<p> </p>
<p>This is really helpful... But I am little new in Birt and I had not used scripting very much.</p>
<p> </p>
<p>As far as I understand, you are creating data set through script in the example file. I am creating data source through RestAPI. Can you please give an example with rest api data source.</p>
Clement Wong
<p>Oh, you didn't specify via REST API. That's easier. For my latest attached example, I'm assuming it's JSON returned. I am using a sample JSON and looking at one of the returned values to generate the # of images based on that value.</p>
<p> </p>
<p>You'll see in the beforeFactory, we are using reading the results from the sample REST API into a JSON object.</p>
<p> </p>
<p>If you want to test with different # of images, you can comment/uncomment to use one of these lines:</p>
<p style="margin-left:40px;"> </p>
<p style="margin-left:40px;"><span style="font-family:'courier new', courier, monospace;">//Let's see how many records we bring back. This sample has 3 records.<br>
//<br>
theCount = json.Localities.length;<br>
//<br>
//For testing, this one has 1 record<br>
////theCount = json.NumberOfSeats;<br>
//<br>
//For testing, this one has 5 records<br>
////theCount = json.Locality[1].Candidates[4].Votes;</span><br>
</p>
<p> </p>
<p>I'm combining the technique I use in my DevShare (<a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/files/file/1128-querying-elasticsearch-with-birt-using-a-scripted-data-set/'>http://developer.actuate.com/community/forum/index.php?/files/file/1128-querying-elasticsearch-with-birt-using-a-scripted-data-set/</a>)
with the previous example.</p>
<p> </p>
<p>If you are using BIRT 4.5.0, it has built-in JSON support so you don't need the helper JavaScript file, "json.js", in the root of your project folder. The difference between the two designs in the ZIP is that the one for pre-BIRT 4.5.0, there is an external Resources reference to "json.js", and the one for 4.5.0 does not have it. If you don't have it in pre-BIRT 4.5.0, when attempting to run the report, you will see an error like <em>... ReferenceError: "JSON" is not defined.</em></p>
<p> </p>
<p>And, BTW, my first name is Clement, and not Wong.</p>
anitaV
<p>Hi Clement,<br>
<br>
Thanks for the reply.. this is really very helpful and solved my problem.</p>
<p> </p>
<p>Can you please tell me one more thing here. In place of using URL for JSON, can't we use our data source 'HttpRequest' URL here?</p>
<p> </p>
<p>Also sorry for calling you Wong..
</p>
Clement Wong
<p>Yes, you should be able to use your data source URL although I'm not sure what that is and what format it is returning.</p>