Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » accessing data between tables with different databinding(and how to hide rows depending values)
icon5.gif  accessing data between tables with different databinding [message #932945] Thu, 04 October 2012 15:42 Go to next message
Blaine Mising name is currently offline Blaine Mising nameFriend
Messages: 25
Registered: December 2010
Junior Member
I've a report that contains some tables, and each table has a different dataset to show different information of same product.
These tables are inside a "global" table. The global table shows some columns of products (ID, description...) other table shows different information about the product like the historical of prices of the current product.
Other table shows the las status of the current product (if it is in stock or not)

I want to show in the footer row of "global" table some aggregations.

For example:
1. Count and show the total of products. This is easy. I can do an aggregation counting "id" rows
2. Count and show the products which are in stock. Here is my problem. I don't know how can I access in my global table to data that is in other table/dataset

I can put other status product table, but I think that this is not a clean solution.
I think that I can do it with global variables.

What is the best way to access data from different datasets?

[Updated on: Thu, 04 October 2012 15:45]

Report message to a moderator

Re: accessing data between tables with different databinding [message #932996 is a reply to message #932945] Thu, 04 October 2012 16:38 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Is a multi data set cube with a crosstab not an option. You could always do this with script. Take a look at this thread:
http://www.eclipse.org/forums/index.php/t/391444/

Jason
Re: accessing data between tables with different databinding [message #936807 is a reply to message #932945] Mon, 08 October 2012 11:08 Go to previous messageGo to next message
Blaine Mising name is currently offline Blaine Mising nameFriend
Messages: 25
Registered: December 2010
Junior Member
Thanks for your help.

I can do it with variables, as you did in the report example.

How can I get the time (in HH:MM format) between two dates?

My report shows when a product is bought (a databinding) and sold (other databinding). I want to show in other column the time elapsed between these events.

For example:

-----PRODUCT ID ------ BOUGHT ------------------ SOLD --------------ELAPSED TIME ------
------1-------- ----2012-01-01 10:00:00-------2012-01-02 10:01:00-----24:01:00---------
(Dates are in YYYY-MM-dd HH:MM:SS format)

The bough and sold dates are stored in global variables, then I did a databinding "time" object, and in "create" script I tried this:

this.setDisplayValue(reportContext.getGlobalVariable("BDATE") - reportContext.getGlobalVariable("SDATE"));

but it doesn't work.

I tried:

var diffMin = BirtDateTime.diffMinute(reportContext.getGlobalVariable("BDATE"),reportContext.getGlobalVariable("SDATE"));

if(diffMin>15){
this.setDisplayValue(difMin);
}else{
this.setDisplayValue("");
}


This shows the minutes, but not in HH:MM format, for example: 130 (02:10)
How can I show it in HH:MM format?





[Updated on: Mon, 08 October 2012 12:57]

Report message to a moderator

Re: accessing data between tables with different databinding [message #937342 is a reply to message #936807] Mon, 08 October 2012 22:42 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Is the data type for the expression a string? You should be able to do something like

var hrs = parseInt(diffMin/60);
var mins = diffMin % 60;

this.setDisplayValue(hrs+":"+mins);

Jason
Re: accessing data between tables with different databinding [message #938094 is a reply to message #937342] Tue, 09 October 2012 14:40 Go to previous messageGo to next message
Blaine Mising name is currently offline Blaine Mising nameFriend
Messages: 25
Registered: December 2010
Junior Member
Thank you very much!!

I've a problem, and I don't know if its a bug of Birt 4.2.0 or I am doing something wrong.

I've the Bought and sold dates of each product in 2 global variables.

I've 2 data objects, one for purchase date and the other for sale date. These objects are datetime, and expression value is this.setDisplayValue(reportContext.getGlobalVariable("BDATE")); for purchase date, and this.setDisplayValue(reportContext.getGlobalVariable("SDATE")); for sale date.

When I preview the report, eclipse shows data correctly, but when I deploy and run the report in my browser the dates of 2 objects doesn't appear correctly.

I changed them with 2 labels with this.text = reportContext.getGlobalVariable("BDATE"); and this.text = reportContext.getGlobalVariable("SDATE"); and dates appears correctly in browser mode too.
I want to use data objects because they format dates automatically. How can I format dates as data objects does?

Why is not working with data bindings objects? It's a bug? How can I solve it?




[Updated on: Tue, 09 October 2012 14:46]

Report message to a moderator

Re: accessing data between tables with different databinding [message #938303 is a reply to message #938094] Tue, 09 October 2012 18:56 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Can you log out the data type that getGlobalVariable is returning?

var tst = reportContext.getGlobalVariable("BDATE")

importPackage( Packages.java.io );
out = new PrintWriter( new FileWriter( "c:/temp/datatype.txt", true ) );
out.println( "Data type "+tst.getClass());
out.close();

Jason
Re: accessing data between tables with different databinding [message #939215 is a reply to message #938303] Wed, 10 October 2012 14:29 Go to previous messageGo to next message
Blaine Mising name is currently offline Blaine Mising nameFriend
Messages: 25
Registered: December 2010
Junior Member
I did it and is a java.util.Date object

I solved it with labels and this code in onCreate method:

importPackage( Packages.java.text );
var mydt1 = reportContext.getGlobalVariable("BDATE");
var sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm", reportContext.getLocale());
var mydtf1 = sdf.format( mydt1 );
this.text = mydtf1;

But I don't understand why is not working with edit objects. I updated to Birt 4.2.1 but with same results. Can be a bug?

I've other problem, I want to check if products are delayed or not, and if they are not delayed, hide all the row, because the table has a databinding with all the products.
I implemented the code in Visibility expression property of the row, and it works fine, only products delayed are shown, but the pages in browser has different number of visible rows.
It happens because birt takes account the number of total rows, and not only visible rows. For example, the second page only shows 3 products, and the third page shows 15.

How can I solve this and show the same number of visible rows per page?





[Updated on: Wed, 10 October 2012 14:46]

Report message to a moderator

Re: accessing data between tables with different databinding [message #939853 is a reply to message #939215] Thu, 11 October 2012 05:04 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Can you post the expression you are using for visibility? Better yet can you reproduce the issue with a sample report that we can run? It would be good if it could show both issues.
You can use a csv data file for the sample if you would like, just post it as well.


Jason

Re: accessing data between tables with different databinding [message #940401 is a reply to message #939853] Thu, 11 October 2012 15:51 Go to previous messageGo to next message
Blaine Mising name is currently offline Blaine Mising nameFriend
Messages: 25
Registered: December 2010
Junior Member
The visibility expression is this:

var actualSts = reportContext.getGlobalVariable("actualStatus");
var canVal = reportContext.getMessage("cancel.status", reportContext.getLocale());
if(actualSts ==null){
actualSts = "";
}

if(!actualSts .equals(canVal)){
if(BirtDateTime.diffMinute(reportContext.getGlobalVariable("BDATE"),reportContext.getGlobalVariable("SDATE"))<=3600){
true;
}else{
false;
}
}else{
false;
}

I will try to generate a simple report and post here.
Re: accessing data between tables with different databinding [message #941693 is a reply to message #940401] Fri, 12 October 2012 19:26 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Ok post the example when you get a chance. Also on the table try setting the pagebreakinterval to 0, in the page break general property for the table.

Jason
Re: accessing data between tables with different databinding [message #946618 is a reply to message #941693] Tue, 16 October 2012 10:47 Go to previous message
Blaine Mising name is currently offline Blaine Mising nameFriend
Messages: 25
Registered: December 2010
Junior Member
I tried pagebreakinterval option and now works, but the first page has only the report header, without data. The next pages has the same number of elements.

I will try to post a basic example the next week.
Previous Topic:BIRT : Styles overlapping in HTML Page
Next Topic:BIRT 4.2 "available column bindings" is missing on chart reports
Goto Forum:
  


Current Time: Fri Mar 29 00:37:27 GMT 2024

Powered by FUDForum. Page generated in 0.02673 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top