quebra coluna (birt duplicate rows)

Upload: tiagovanderlei

Post on 05-Apr-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 Quebra Coluna (BIRT Duplicate Rows)

    1/4

    http://birtworld.blogspot.com/2010/10/birt-duplicate-rows.htmlBIRT Duplicate Rows

    Currently BIRT supports suppressing duplicate columns values. To do this you can select thetable column and in the general properties click the Suppress duplicates checkbox.

    This will have an effect similar to the following image.

    You will notice that the number of rows generated in the table has not changed, but noorder number is repeated. If your table does contain duplicate rows, meaning each columnin the table has the same data as the row before and you suppress duplicates on eachcolumn, the number of rows displayed by BIRT will be reduced. For example assume your

    table is tied to a dataset that has two columns and every row contains the same data.

    http://birtworld.blogspot.com/2010/10/birt-duplicate-rows.htmlhttp://birtworld.blogspot.com/2010/10/www.eclipse.org/birthttp://birtworld.blogspot.com/2010/10/www.eclipse.org/birthttp://birtworld.blogspot.com/2010/10/birt-duplicate-rows.html
  • 7/31/2019 Quebra Coluna (BIRT Duplicate Rows)

    2/4

    If this dataset is bound to a table and both columns are set to suppress duplicates thefollowing will be displayed.

    The actual number of rows is not reduced but the table only shows the value for one row. Inthe generated HTML a TR element is created for each empty row with empty values. If youuse this approach make sure to set the padding on the table row, cell, and data items to 0or you will get unwanted space for empty rows. It is also important to realize that theseempty rows are counted if you are use the page break interval property to handle pagebreaks. As a side note, when dealing with duplicate rows it is often better to allow thedatabase to handle culling repeated rows, but in some cases like flat file data sources thismay not be an option.

    Another option that can be used to hide duplicate rows is scripting and a visibilityexpression.

    Assume we have a table that shows order numbers. If we only want a particular ordernumber to be shown once, we obviously could use a distinct on the query. If that is not anoption you can use a script and a visibility expression to implement this requirement. On thetable rows onCreate method you could enter a script like:

    var rowLast = this.getRowData().getColumnValue("ORDERNUMBER");

    reportContext.setGlobalVariable("rl", rowLast);

  • 7/31/2019 Quebra Coluna (BIRT Duplicate Rows)

    3/4

    And a visibility expression like:

    if( row["ORDERNUMBER"] == reportContext.getGlobalVariable("rl") ){

    true;

    }else{

    false;

    }

    This will cause the BIRT engine to only show the row if its current row order number isdifferent from the previous row.

    As with the previous examples and all visibility operations the underlying data is not altered.

    It is just not displayed. For example if you hide a table the dataset still executes. If youwant to alter the underlying data you will need to filter the data either on the table or theactual dataset. This can be difficult when trying to get a rows previous value so I created asimple aggregate extension Plugin that will do this for you. It is based on Scotts poston Optimistic sums. The extension point has been revised slightly since that post so take alook at the attached examples to see the source code. The extension point adds a previousvalue aggregate function to BIRT. To use it you can create a computed column on thedataset.

    The function stores the last row value as entered in the Column expression. Once thecomputed column is added to the dataset you can then select the filters tab and enter afilter like:

    http://birtworld.blogspot.com/2006/09/optimistic-sums.htmlhttp://birtworld.blogspot.com/2006/09/optimistic-sums.html
  • 7/31/2019 Quebra Coluna (BIRT Duplicate Rows)

    4/4

    This will filter the dataset as shown below.

    The source for this post is available at Birt-Exchange. The download contains two reports(one that uses the aggregate function and one that was demonstrated earlier in the post),the exported new aggregate plugin, and a source project for the plugin.

    http://www.birt-exchange.org/org/devshare/designing-birt-reports/1271-birt-duplicate-rows/http://www.birt-exchange.org/org/devshare/designing-birt-reports/1271-birt-duplicate-rows/