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)
Not able to create custom data set
Shakuntala Chaya
<p>I am very new to BIRT and using BIRT 4.5.</p>
<p> </p>
<p>I am using XML data source which is having the container tag , textual and numerical parameter tag inside it.</p>
<p> </p>
<p>container can have sub container of same container type and parameters also. Now the problem is while creating the data set I am able to set all numerical parameters in one column and all textual parameters in one column.</p>
<p> </p>
<p>Instead of this I want to create separate column for each parameter. Can any body help me out how to create customized columns with an example.</p>
<p> </p>
<p>thanks in advance</p>
Find more posts tagged with
Comments
Clement Wong
<p>Sorry, for me, it's difficult to picture your requirements.</p>
<p> </p>
<p>Do you have any sample data of your XML, or made-up data that you can illustrate what you are looking for?</p>
<p> </p>
<p>Also, a mock-up or sample of what you are looking for in the output would be helpful.</p>
Shakuntala Chaya
<p>Thanks for your reply..............</p>
<p> </p>
<p>below is the input xml file how it looks.........</p>
Clement Wong
<p>And please also specify what output you would like to see based on that sample.</p>
Shakuntala Chaya
<p>and the out put will be in the format which is in attached file</p>
Shakuntala Chaya
<pre class="_prettyXprint _lang-nocode">
and for inner containers I have to provide hyper link..................on click of hyper link it should go to respective table(which is also created as same way like above one) of that selected container
</pre>
Shakuntala Chaya
<p>thanks in advance............</p>
Shakuntala Chaya
<p>can anybody help me out in that.........I am trying since 2 weeks</p>
Shakuntala Chaya
<p>For this requirement I tried to create the data set in data explorer but I didn't get the proper output which I want..</p>
<p> </p>
<p>So I am trying to create the table and filling dynamic data inside it manually means programmatically using design engine API.</p>
<p> </p>
<p>and I am able to apply the hyper link for inner containers also but the problem is I don't know how to pass the control from one table to</p>
<p> </p>
<p>another table on click of hyper link using design Engine API. The code which I am using to create the hyper link is posted in the topic</p>
<pre class="_prettyXprint _lang-">
Not able to add hyper link in the table cell
</pre>
<p>"</p>
Clement Wong
<p>Attached is one solution to your first requirement of populating the data. It is based on the DevShare using E4X for parsing XML (<a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/files/file/1122-parsing-xml-in-birt-with-e4x/'>http://developer.actuate.com/community/forum/index.php?/files/file/1122-parsing-xml-in-birt-with-e4x/</a>)
. </p>
<p> </p>
<p>The <em>beforeOpen </em>and <em>fetch </em>events of the scripted data set are where you'll want to look for the scripted code. I added a group to the table by the outer container name, and then dropped the group level items to the the detail level (for reference @ <a data-ipb='nomediaparse' href='
https://enterprisesmartapps.wordpress.com/2011/12/13/birt-drop-group-header-property-and-table-border-lines/).'>https://enterprisesmartapps.wordpress.com/2011/12/13/birt-drop-group-header-property-and-table-border-lines/).</a></p>
;
<p> </p>
<p>
Shakuntala Chaya
<p>thanks for your reply................</p>
<p> </p>
<p>but my problem is I am able to create and fill the data using Design engine API, no data source and data set is created in the data explorer because every thing I am doing programmatically.</p>
<p> </p>
<p>is there any way to link two tables programmatically using design engine API</p>
Shakuntala Chaya
<p>I think I have to create the data source and data set also progrmmatically</p>
Clement Wong
<p>Yes, if your XML is dynamic then you will need to create the data source and data set programmatically.</p>
Matthew L.
<p>Hello sc560,</p>
<p> </p>
<p>While I don't have an example for an XML Data Source specifically, you can get some ideas for creating a Data Source/Set using API from the following example:</p>
<p><a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/35930-running-a-query-in-the-initalize/?p=133369'>http://developer.actuate.com/community/forum/index.php?/topic/35930-running-a-query-in-the-initalize/?p=133369</a></p>
;
<p> </p>
<p>Also could you explain the question <em>"</em><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;"><em>is there any way to link two tables programmatically using design engine API"</em> in more detail?</span></p>
<p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">What exactly are you wanting to accomplish between two tables?</span></p>
<p> </p>
<p>You also mentioned hyperlinking, here is some example API code that creates a hyperlink on an existing label, hopefully it is helpful for you:</p>
<pre class="_prettyXprint _lang-js">
importPackage(Packages.org.eclipse.birt.report.model.api);
importPackage(Packages.org.eclipse.birt.report.model.api.elements);
var reportDesignHandle = reportContext.getDesignHandle(); //ReportDesignHandle
var elementFactory = reportDesignHandle.getElementFactory(); //ElementFactory
var label = reportDesignHandle.findElement("MyLabel");
label.setText("link");
label.setBookmark("\"MyLabel\"");
var actionHandle = label.setAction(StructureFactory.createAction());
actionHandle.setLinkType(DesignChoiceConstants.ACTION_LINK_TYPE_DRILL_THROUGH);
actionHandle.setReportName("MyNewReportToLinkTo.rptdesign");
actionHandle.setTargetFileType("report-design");
actionHandle.setTargetWindow("_self");
actionHandle.getMember("paramBindings");
var paramBinding = StructureFactory.createParamBinding(); //ParamBinding
paramBinding.setParamName("MyParameterNameInMyNewReportToLinkTo"); //ex: "NewParameter"
paramBinding.setExpression("\"MyValueToPassThroughTheParameter\"");
actionHandle.addParamBinding(paramBinding);
</pre>
Shakuntala Chaya
<p>Hello Mattew L,</p>
<p> </p>
<p> Thanks for your reply. Here I am attaching the output format how it should be, which I posted earlier. My report may contain 1 to 50 tables and in that report I have to provide the hyper link for inner containers and that inner container have the separate table with its parameters and some inner containers.</p>
<p>On click of that inner container hyper link the control should pass to its respective table. The data which I am filling in those tables and column headers also will be changing for every execution. I am able to apply the link for inner containers using " DesignChoiceConstants.ACTION_LINK_TYPE_DRILL_THROUGH " but I don't know how to pass the control.</p>
<p> </p>
<p>Even I tried with "DesignChoiceConstants.ACTION_LINK_TYPE_BOOKMARK_LINK ",but no link is applied for inner container.</p>
<p> </p>
<p>Can any body have a solution how to pass the control to respective table out of a collection of tables.</p>
<p> </p>
<p>Thanks in advance.</p>
Shakuntala Chaya
<p>Hello Matthew L ,</p>
<p> </p>
<p> I tried with the code which you have posted.</p>
<p> </p>
<p>In paramBinding.setParamName(" ") and paramBinding.setExpression(" ") ,I don't know which string I have to pass, because i am not</p>
<p> </p>
<p>creating any datasource ,dataset and inputParameters in data explorer.</p>
<p> </p>
<p>creating tables and passing data in to tables everything i am doing dynamically using design engine API without creating data set and data source.</p>
<p> </p>
<p>thanks in advance</p>
Matthew L.
<div>The paramBinding is only needed if you drill through to another report design (or re-run the same report design) and need to pass a parameter value to the new report.</div>
<div> </div>
<div>Do you have an rptdesign example that I could look at to see what you are wanting to accomplish?</div>
<div> </div>
<div>Also you mentioned "<span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">to pass the control to respective table out of a collection of tables."</span></div>
<div><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">Are you wanting to click on a link "innercontainer 2" and have the browser screen scroll to table 2 (or hide table 1 and show table 2)?</span></div>
Shakuntala Chaya
<p>Yes........On click of "innerContainer2" the browser screen scroll to table2 and no need of hiding table1</p>
<p> </p>
<p>and here I am not passing any parameter value to new report just screen should scroll to table2.</p>
<p> </p>
<p>Also provide some example code how to set limited number of tables in one page and how to shrink the table columns and how to set the heading for report.</p>
<p> </p>
<p>Thanks n advance</p>
Matthew L.
<p>Here is code to set an Action on a Label's handle:</p>
<pre class="_prettyXprint _lang-js">
importPackage(Packages.org.eclipse.birt.report.model.api); //For StructureFactory
importPackage(Packages.org.eclipse.birt.report.model.api.elements); //For DesignChoiceConstants
var label = reportContext.getDesignHandle().findElement("MyLabelLink"); //Get element to apply link
var actionHandle = label.setAction(StructureFactory.createAction()); //Create action
actionHandle.setLinkType(DesignChoiceConstants.ACTION_LINK_TYPE_BOOKMARK_LINK); //Set action type
actionHandle.setBookmarkLink("\"MyBookmarkNameForTable2\""); //Set link-to expression
</pre>
<p>Since you are building the report with the API, you can replace line 3 ( the findElement line) and use the variable that contains the label handle you build with API code.</p>
<p> </p>
<p>As for your other questions:</p>
<p>"How to set limited number of tables in one page": I am not sure what you are referring to. Are you wanting to limit the amount of rows per table?</p>
<p>Or if you are wanting to have 2 tables per page then code a page-break-after = always on every other table.</p>
<p> </p>
<p>For the column shrink, you can adjust the table columns by defining their size using the ColumnHandle of the table:</p>
<pre class="_prettyXprint _lang-js">
var tableHandle = reportContext.getDesignHandle().findElement("Table1"); //Get table handle
var columnHandle = tableHandle.getColumns().get(0); //Get first column (Zero-based)
columnHandle.setProperty("width","10pt"); //%,cm,em,ex,in,mm,pc,pt,px
</pre>
<p>To set a report heading, you can refer to this post: <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/36698-dynamic-table-header-on-pagebreak/?p=136572'>http://developer.actuate.com/community/forum/index.php?/topic/36698-dynamic-table-header-on-pagebreak/?p=136572</a></p>
;
Shakuntala Chaya
<p>Thank you for your reply..................</p>
<p> </p>
<p>I tried with the code which you have posted.But screen is not scrolling to table2.</p>
<p> </p>
<p>And i am not understanding the method " actionHandle.setBookMarkLink(" \ "mybookMarkNameFortable2\" ") " which String do i need to pass to this method because i am not setting any bookmark for table2.</p>
<p> </p>
<p>So i tried this code to set the bookMark on table2.</p>
<pre class="_prettyXprint">
table.setBookmarkDisplayName("InnerContainer2");
table.setBookmark("InnerContainer2");
</pre>
<p>The same string "InnerContainer2" i am passing to</p>
<pre class="_prettyXprint _lang-">
actionHandle.setBookMarkLink("InnerContainer2");
</pre>
<p>but still it is not working</p>
<p> </p>
<p>I think i am not following the proper way.</p>
Shakuntala Chaya
<p>On click of InnerContainer2 hyper link in browser i am getting the URL </p>
<p> </p>
<p>myreportLocation/myReportName#innercontainer2</p>
<p> </p>
<p>I think from this you can find out the mistake which i did,</p>
<p> </p>
<p>One more thing, i am setting the same column header for the column which is having the hyper link in one table and for first column in table2, which is shown in attachment.Is it will cause any conflict??</p>
<p> </p>
<p>Can you just explain me which string i have to pass for setBookMarkLink( " ") method</p>
Matthew L.
<p>The bookmarks are JavaScript expressions, because of this try setting the bookmark like the following:</p>
<pre class="_prettyXprint _lang-js">
//Use \" to escape the double quotes and set the expression as a string instead of a variable.
//Example:
//If you use the following: table.setBookmark("InnerContainer2");
//This will set the bookmark to the value of a variable called InnerContainer2.
//However if you would like to set the bookmark with a hard-coded string, you must add double quotes
//around the value to indicate it's a string. To do this, you must escape double quotes around the
//string you wish to set the bookmark with.
//Like this:
table.setBookmark("\"InnerContainer2\""); //Note that we escape the double quotes \" around the string
</pre>
<p>You should also escape the double quotes around all hard-coded string values you wish to set.</p>
Shakuntala Chaya
Thanks for your response....one more issue is, in my report some column headers are having 20 to 30 character size which are making my report large.So I want to rotate the label vertically.I tried with "vertical-align "and "text-align" properties on label handle object but it didn't work for me.Is there any way to rotate the label vertically or set the column header vertically in table....give me some example code. Thanks in advance
Matthew L.
<p>I know of two ways to accomplish text rotation in BIRT.</p>
<p>The easy way is to use a plugin: <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/39246-rotate-text-90-degrees/'>http://developer.actuate.com/community/forum/index.php?/topic/39246-rotate-text-90-degrees/</a></p>
;
<p> </p>
<p>Or you can rotate text in pure code: <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/36636-properly-displaying-a-barcode-when-rotated-90-degrees/?p=136481'>http://developer.actuate.com/community/forum/index.php?/topic/36636-properly-displaying-a-barcode-when-rotated-90-degrees/?p=136481</a></p>
;
Shakuntala Chaya
<p>Hello Matthew L,</p>
<p> </p>
<p>Thank you very much for your help. Rotated Text is working fine.</p>
<p> </p>
<p>But still that hyper link is not working ,the browser is not scrolling to respective table.</p>
<p> </p>
<p>Here I am attaching the code which I am using.</p>
<pre class="_prettyXprint _lang-nocode">
Action ac = StructureFactory.createAction();
ActionHandle actionHandle = containerData.setAction(ac);
actionHandle.setLinkType(DesignChoiceConstants.ACTION_LINK_TYPE_BOOKMARK_LINK);
actionHandle.setReportName("new_report_1.rptdesign");
actionHandle.setTargetFileType("report-design");
actionHandle.setBookmarkLink("\""+DynamicString+"\"");
</pre>
<p>In setBookMarkLink method I am passing the dynamic string which can be set at the time of execution.</p>
<p> </p>
<p>Can anybody have a solution to scroll the bowser to respective table.</p>
<p> </p>
<p> </p>
<p>Thanks in advance.</p>
Matthew L.
<p>If you could post your whole report design I can look through it to determine what the issue is.</p>
<p> </p>
<p>Also, I've attached a simplified pure API design that creates 2 tables and sets 1 hyperlink on each table that links to the other table as an example.</p>
Shakuntala Chaya
<p>Hello Matthew L,</p>
<p> </p>
<p>I got it
.</p>
<p> </p>
<p>I done the mistake while setting the BookMark for table.</p>
<p> </p>
<p>I have gone through your rpt file. Now Hyperlink is working fine.</p>
<p> </p>
<p>Thank you very much for your help.</p>
Shakuntala Chaya
<p>Can you have any idea of how to set the hyper link for some portion of string.</p>
<p> </p>
<p>Like, My String is :</p>
<p> </p>
<p>"No of XXXX containers" which is set as a text for lable.</p>
<p> </p>
<p>In that I want the hyper link for "XXXX" string which is set dynamically.</p>
<p> </p>
<p>Thanks in advance.</p>
Matthew L.
<p>This can be accomplished by using text elements (with html) instead of data elements.</p>
<p>See attached design for example</p>
<pre class="_prettyXprint _lang-js">
//Hyperlink within string setup
var textElementString = "<div id=\"ReferenceDiv\"></div> <!--Reference div for output display -->"
+ "<script type=\"text/javascript\">\n"
+ "var tmp = \"<VALUE-OF>row[\"No of XXXX containers\"]</VALUE-OF>\";//Get row value\n"
+ "tmp = tmp.split(\" \");//Split words\n"
+ "var link = tmp[0] + \" \" + tmp[1] + \" <a href=\\\"https://www.google.com/search?q=\" + tmp[2] + \"\\\">\" + tmp[2] + \"</a> \" + tmp[3];//Build string\n"
+ "var div = document.getElementById(\"ReferenceDiv\");//Get reference div tag\n"
+ "div.innerHTML = link;//Set href string to the div tag\n"
+ "if(!window.a){a=window.a=0;}else{a=window.a;}//Set window.a if not previously set\n"
+ "a++; window.a = a;//Increment a and update window.a value\n"
+ "div.setAttribute(\"id\", \"ReferenceDiv_\" + a);//Increment the div tag so the next loop doesnt effect this current one\n"
+ "</script>"
//Set Detail Row with text element
var textItem = elementFactory.newTextItem("TextElement"); //Create text element
textItem.setContentType("html"); //Set type as html
textItem.setContent(textElementString); //Set content with textElementString value
</pre>
Shakuntala Chaya
<p>Hello Matthew,</p>
<p> </p>
<p> I got one more issue. I am saving the report in HTML format. If i open the report in another system, the rotated text</p>
<p> </p>
<p>(ExtendedItemHandle object) is not displaying in the report(In internet Explorer browser) and displaying as an image symbol in firefox i am using the same version of Firefox (46.0.1) in both systems.</p>
<p> </p>
<p>But in my system its working fine.</p>
<p> </p>
<p>Find the attachments of reports which are opened in internet explorer and Firefox.</p>
Matthew L.
<p>You should use the browsers debug tools to determine the cause (ex: F12 in Chrome).</p>
<p>However the <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/39246-rotate-text-90-degrees/'>Rotated
Text Plugin</a> (as well as the <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/36636-properly-displaying-a-barcode-when-rotated-90-degrees/?p=136481'>pure
code example</a>) takes input text and creates an image for the appearance of rotated text.</p>
<p>Most likely the HTML output cannot locate the rotated text images generated by the plugin as they were never generated in that browsers cache.</p>
<p>You will need to use your browsers debug tools to verify this.</p>