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)
Populatind report library elements using DEAPI from beforeFactory method
actuser9
<p>Hi,</p><p> </p><p>I am trying to get the elements from the report library into the report using the deapi in the beforeFactory method of the report.</p><p> </p><p>My report library has the following elements.</p><p>- An empty grid with two rows.</p><p>- Line Chart</p><p>- Bar Chart</p><p> </p><p>Using the before factory method, I would like to get the grid and place the line chart and bar chart in each of the rows. Any inputs are highly appreciated.</p><p> </p><p>Thanks,</p><p>UY</p>
Find more posts tagged with
Comments
micajblock
<p>Maybe this will help.</p><p> </p><p><a data-ipb='nomediaparse' href='
http://www.birt-exchange.org/devshare/_/designing-birt-reports/1495-dynamic-content-from-library'>http://www.birt-exchange.org/devshare/_/designing-birt-reports/1495-dynamic-content-from-library</a></p>
;
actuser9
<p>Hi mblock,</p><p> </p><p>Thanks for the quick response. I have been using the same code to acheive what I am looking for. In the example, the report library has the grid along with the charts which is being populated.</p><p> </p><p>Basically for my reporting need, I need to get the empty layout(for instance, a grid with two rows) from the report library and then add the two charts to it in the beforeFactoy code. Any help is appreciated.</p>
micajblock
<p>Sorry, I am not sure how. Maybe someone with more DEAPI experience than I will help.</p>
actuser9
<p>Hi,</p><p> </p><p>Is it possible with DEAPI? or DE API only allows creating new elements on the fly and does not allow to use the elements from the report library? Please clarify.</p>
micajblock
<p>The BD Pro UI uses the DEAPI for everything. So if it possible to do something in the UI it is possible in code. Q</p>
actuser9
<p>Thank you. That is my understanding too.</p><p> </p><p>Appreacite any help with this.</p>
actuser9
<p>Hi,</p><p> </p><p>I have been going through the design engine documentation to find the classes that would be useful in populating the report library elements and would be able to edit the report library elements in the before factory code. Not much luck with this.</p><p> </p><p>A simple trial is to get the grid with two empty rows from the report library and be able to add new content into the empty rows of the grid. Any suggestions?</p>
micajblock
<p>I am not sure the exact code but below is a code snippet of a java program that adds a data item to a table cell, hope this points you in the right direction.</p><p> </p><div><pre class="_prettyXprint">// table detailRowHandle tabledetail = (RowHandle) table.getDetail( ).get( 0 );CellHandle mydatacell = (CellHandle) tabledetail.getCells( ).get( 0 );DataItemHandle data = designFactory.newDataItem( "data_1" );data.setResultSetColumn( "MyCol1");mydatacell.getContent( ).add( data ); </pre></div>
actuser9
<p>Thank you mblock.
I have tried to add a label to the grid cell as in the report attached below. Works fine since the label is created as a new element. And then extending it, I am using a chart with in the report body to be placed in the grid cell which fails. Error log shown as "The parent element "mychart" is not the top-level report item in components."
Any ideas? The report is attached for your reference.</p><p> </p><p>
micajblock
<p>Can you explain in words the business case? Why are you trying to do this?</p>
actuser9
<p>Hi,</p><p> </p><p>I am glad I got that to work based on your post and JasonW. Thank a lot!!! Now lot more to do with the parameter implementation.</p><p> </p><p>The business case is user wants to choose the custom layout. The layout can be anything like grid with two rows, grid with two columns and gris with two rows and two columns etc., And user would also choose the report content(available in the report library) that should be part of these grid cells. The layouts(grids) and reports(chart/tables) will be part of the report library which have to be populated from the beforefactory code based on layout/reports as parameters.</p><pre class="_prettyXprint _lang-js">var libhandle = reportContext.getDesignHandle().getLibrary("Development_Library");var elementFactory = reportContext.getDesignHandle().getElementFactory( ); if ( libhandle != null ){ //adding the layout to the report grid = libhandle.findElement("TwoQuadrantHorizontal"); //get row1 of the layout var row1 = grid.getRows( ).get( 0 ); var cell1 = row1.getCells( ).get( 0 ); //get row2 of the layout var row2 = grid.getRows( ).get( 1 ); var cell2 = row2.getCells( ).get( 0 ); //add chart1 to the grid from the report library var Row1 = elementFactory.newElementFrom(libhandle.findElement("NewTable"), "1" ); //add chart2 to the grid from the report library var Row2 = elementFactory.newElementFrom(libhandle.findElement("NewChart"), "2" ); cell1.getContent( ).add( Row1 ); cell2.getContent( ).add( Row2 ); var grid1 = elementFactory.newElementFrom(grid, "Grid1"); reportContext.getDesignHandle().getBody().add( grid1 );} </pre>
actuser9
<p>If you think of better way of doing this, please let me know.</p>
micajblock
<p>UY,</p><p>I know that the member apaine has built this exact application (including UI). Maybe you can message him and he can give you some tips. Or even better use his services so you do not need to re-invent the wheel.</p>
actuser9
<p>Wow...so good to hear. Thank you!</p>
apaine
<p>Regarding your code, I would put it in onPrepare rather than beforeFactory. If you have it in onPrepare you can then put other code in the onPrepare script of your library elements to dynamically configure them before they are generated.</p><p>Also, I recommend writing as a Java event handler rather than javascript as you can quickly find the quantity of code you need is difficult to manage and debug in javascript.</p><div> </div><p>Getting this sort of code working is pretty easy. The challenge is building a flexible, reusable framework that can be used for different types of content. e.g., what if you want to adjust the size of the components so that one of them spans two columns? </p><p> </p><p>The application I built is a rich framework of UI components to let users configure custom reports via a web interface. Users drag and drop prebuilt library components from a palette to build new designs. They can resize them, change component settings, choose master pages, choose themes etc before saving the result either as metadata to create the report or as the finished report itself.</p><p> </p><p> </p><p> </p><p>There are 100s of hours of work in building such a framework and we could help save you a lot of work if you want to use our help to get started.</p><p> </p><p>Andrew</p>
actuser9
<p>Hi Andrew,</p><p> </p><p>Thanks for throwing some light on this and providing valuable inputs.</p><p> </p><p>I agree with you on the below and suggested the same to my team. But then, we would want to visualize the output right away via report rather than the java program.</p><blockquote class="ipsBlockquote"><p> </p><p>Also, I recommend writing as a Java event handler rather than javascript as you can quickly find the quantity of code you need is difficult to manage and debug in javascript.</p></blockquote>