Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » sort by code
sort by code [message #162922] Fri, 19 May 2006 13:43 Go to next message
Eclipse UserFriend
Originally posted by: barrerager.delsatgroup.com

I'm modifying the webviewer servlet I want the user select the sort colums
for the report at runtime, can someone help me with an example or/and
documentation on how to achieve this.
Thank you in advance.
Barrera, German.
Re: sort by code [message #163561 is a reply to message #162922] Mon, 22 May 2006 19:43 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Can you give an example scenario.
It may be possible to do this without changing the servlet.

Jason

"Barrera, German" <barrerager@delsatgroup.com> wrote in message
news:e4khu1$llb$1@utils.eclipse.org...
> I'm modifying the webviewer servlet I want the user select the sort colums
> for the report at runtime, can someone help me with an example or/and
> documentation on how to achieve this.
> Thank you in advance.
> Barrera, German.
>
>
Re: sort by code [message #163569 is a reply to message #163561] Mon, 22 May 2006 20:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: barrerager.delsatgroup.com

What I'm trying to achieve is to add a dialog like parameters dialog to give
the end user the ability to select which columns of the tables of the report
are visible.

Barrera, German.

"Jason Weathersby" <jweathersby@actuate.com> escribi
Re: sort by code [message #163576 is a reply to message #163569] Mon, 22 May 2006 21:46 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Here is an example of using a parameter to hide a column.
Look at the visibilty property for the column.
This was done in RC3.

Jason

<?xml version="1.0" encoding="UTF-8"?>

<!-- Written by Eclipse BIRT 2.0 -->

<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.2"
id="1">

<property name="createdBy">Eclipse BIRT Designer Version
2.1.0.N20060519-1616 Build &lt;20060519-1616></property>

<property name="units">in</property>

<property name="comments">Copyright (c) 2006 Actuate Corporation.</property>

<parameters>

<scalar-parameter name="custname" id="28">

<property name="valueType">static</property>

<property name="dataType">string</property>

<property name="controlType">text-box</property>

<property name="defaultValue">Atelier graphique</property>

<structure name="format">

<property name="category">Unformatted</property>

</structure>

</scalar-parameter>

<scalar-parameter name="hidecredit" id="29">

<property name="valueType">static</property>

<property name="dataType">boolean</property>

<property name="controlType">check-box</property>

<property name="defaultValue">true</property>

<structure name="format"/>

</scalar-parameter>

</parameters>

<data-sources>

<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc"
name="Data Source" id="4">

<text-property name="displayName">Data Source</text-property>

<property
name="odaDriverClass">org.eclipse.birt.report.data.oda.sampledb.Driver </property>

<property name="odaURL">jdbc:classicmodels:sampledb</property>

<property name="odaUser">ClassicModels</property>

</oda-data-source>

</data-sources>

<data-sets>

<oda-data-set
extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet "
name="Data Set" id="5">

<text-property name="displayName">Data Set</text-property>

<list-property name="parameters">

<structure>

<property name="name">custname</property>

<property name="dataType">string</property>

<property name="nativeDataType">12</property>

<property name="position">1</property>

<expression name="defaultValue">"Atelier graphique"</expression>

<property name="isInput">true</property>

</structure>

</list-property>

<structure name="cachedMetaData">

<list-property name="resultSet">

<structure>

<property name="position">1</property>

<property name="name">CUSTOMERNUMBER</property>

<property name="dataType">integer</property>

</structure>

<structure>

<property name="position">2</property>

<property name="name">CUSTOMERNAME</property>

<property name="dataType">string</property>

</structure>

<structure>

<property name="position">3</property>

<property name="name">CONTACTLASTNAME</property>

<property name="dataType">string</property>

</structure>

<structure>

<property name="position">4</property>

<property name="name">CONTACTFIRSTNAME</property>

<property name="dataType">string</property>

</structure>

<structure>

<property name="position">5</property>

<property name="name">PHONE</property>

<property name="dataType">string</property>

</structure>

<structure>

<property name="position">6</property>

<property name="name">ADDRESSLINE1</property>

<property name="dataType">string</property>

</structure>

<structure>

<property name="position">7</property>

<property name="name">ADDRESSLINE2</property>

<property name="dataType">string</property>

</structure>

<structure>

<property name="position">8</property>

<property name="name">CITY</property>

<property name="dataType">string</property>

</structure>

<structure>

<property name="position">9</property>

<property name="name">STATE</property>

<property name="dataType">string</property>

</structure>

<structure>

<property name="position">10</property>

<property name="name">POSTALCODE</property>

<property name="dataType">string</property>

</structure>

<structure>

<property name="position">11</property>

<property name="name">COUNTRY</property>

<property name="dataType">string</property>

</structure>

<structure>

<property name="position">12</property>

<property name="name">SALESREPEMPLOYEENUMBER</property>

<property name="dataType">integer</property>

</structure>

<structure>

<property name="position">13</property>

<property name="name">CREDITLIMIT</property>

<property name="dataType">float</property>

</structure>

</list-property>

</structure>

<property name="dataSource">Data Source</property>

<property name="queryText">select *

from CLASSICMODELS.CUSTOMERS

where CUSTOMERNAME = ?</property>

</oda-data-set>

</data-sets>

<page-setup>

<simple-master-page name="Simple MasterPage" id="2">

<page-footer>

<text id="3">

<property name="contentType">html</property>

<text-property name="content"><![CDATA[<value-of>new
Date()</value-of>]]></text-property>

</text>

</page-footer>

</simple-master-page>

</page-setup>

<body>

<table id="6">

<property name="width">100%</property>

<property name="dataSet">Data Set</property>

<list-property name="paramBindings">

<structure>

<property name="paramName">custname</property>

<expression name="expression">params["custname"]</expression>

</structure>

</list-property>

<list-property name="boundDataColumns">

<structure>

<property name="name">CUSTOMERNAME</property>

<expression name="expression">dataSetRow["CUSTOMERNAME"]</expression >

<property name="dataType">string</property>

</structure>

<structure>

<property name="name">CUSTOMERNUMBER</property>

<expression name="expression">dataSetRow["CUSTOMERNUMBER"]</expression >

<property name="dataType">integer</property>

</structure>

<structure>

<property name="name">CONTACTLASTNAME</property>

<expression name="expression">dataSetRow["CONTACTLASTNAME"]</expression >

<property name="dataType">string</property>

</structure>

<structure>

<property name="name">CONTACTFIRSTNAME</property>

<expression name="expression">dataSetRow["CONTACTFIRSTNAME"]</expression >

<property name="dataType">string</property>

</structure>

<structure>

<property name="name">PHONE</property>

<expression name="expression">dataSetRow["PHONE"]</expression>

<property name="dataType">string</property>

</structure>

<structure>

<property name="name">ADDRESSLINE1</property>

<expression name="expression">dataSetRow["ADDRESSLINE1"]</expression >

<property name="dataType">string</property>

</structure>

<structure>

<property name="name">ADDRESSLINE2</property>

<expression name="expression">dataSetRow["ADDRESSLINE2"]</expression >

<property name="dataType">string</property>

</structure>

<structure>

<property name="name">CITY</property>

<expression name="expression">dataSetRow["CITY"]</expression>

<property name="dataType">string</property>

</structure>

<structure>

<property name="name">STATE</property>

<expression name="expression">dataSetRow["STATE"]</expression>

<property name="dataType">string</property>

</structure>

<structure>

<property name="name">POSTALCODE</property>

<expression name="expression">dataSetRow["POSTALCODE"]</expression>

<property name="dataType">string</property>

</structure>

<structure>

<property name="name">COUNTRY</property>

<expression name="expression">dataSetRow["COUNTRY"]</expression>

<property name="dataType">string</property>

</structure>

<structure>

<property name="name">SALESREPEMPLOYEENUMBER</property>

<expression
name="expression">dataSetRow["SALESREPEMPLOYEENUMBER"]</expression >

<property name="dataType">integer</property>

</structure>

<structure>

<property name="name">CREDITLIMIT</property>

<expression name="expression">dataSetRow["CREDITLIMIT"]</expression >

<property name="dataType">float</property>

</structure>

</list-property>

<column id="19"/>

<column id="20"/>

<column id="21">

<list-property name="visibility">

<structure>

<property name="format">all</property>

<expression name="valueExpr">params["hidecredit"]</expression>

</structure>

</list-property>

</column>

<header>

<row id="7">

<cell id="8">

<label id="22">

<text-property name="text">CUSTOMERNAME</text-property>

</label>

</cell>

<cell id="9">

<label id="24">

<text-property name="text">CONTACTFIRSTNAME</text-property>

</label>

</cell>

<cell id="10">

<label id="26">

<text-property name="text">CREDITLIMIT</text-property>

</label>

</cell>

</row>

</header>

<detail>

<row id="11">

<cell id="12">

<data id="23">

<property name="dataSet">Data Set</property>

<property name="resultSetColumn">CUSTOMERNAME</property>

</data>

</cell>

<cell id="13">

<data id="25">

<property name="resultSetColumn">CONTACTFIRSTNAME</property>

</data>

</cell>

<cell id="14">

<data id="27">

<property name="resultSetColumn">CREDITLIMIT</property>

</data>

</cell>

</row>

</detail>

<footer>

<row id="15">

<cell id="16"/>

<cell id="17"/>

<cell id="18"/>

</row>

</footer>

</table>

</body>

</report>

"Barrera, German" <barrerager@delsatgroup.com> wrote in message
news:e4t78q$qn1$1@utils.eclipse.org...
> What I'm trying to achieve is to add a dialog like parameters dialog to
> give
> the end user the ability to select which columns of the tables of the
> report
> are visible.
>
> Barrera, German.
>
> "Jason Weathersby" <jweathersby@actuate.com> escribi
Re: sort by code [message #163812 is a reply to message #163576] Tue, 23 May 2006 14:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: barrerager.delsatgroup.com

This works fine but I want to do this for every column in every report, thus
i want to do this by code automatically. Also in my previous post I've
confussed the requirement. I'v started asking how to include sorts
dinamically an later I've asked how to hide columns, sorry for this
confussion.
We're planning to do several improvements to the web viewer so we need
documentation and examples on how to modify the report design at runtime.
We're having problems trying to figure out how to access and modify the
diferent parts of the report design, such as filters, orders, colums,
groups, totals, etc.
Thank you.

Barrera, German.

"Jason Weathersby" <jweathersby@actuate.com> escribi
Re: sort by code [message #163902 is a reply to message #163812] Tue, 23 May 2006 21:30 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Here is an example of how to modify the first visibility rule on a column.
This will change the example I posted earlier.

Jason


import java.io.IOException;

import java.util.Iterator;


import org.eclipse.birt.report.model.api.ColumnHandle;

import org.eclipse.birt.report.model.api.DesignConfig;

import org.eclipse.birt.report.model.api.DesignEngine;

import org.eclipse.birt.report.model.api.DesignFileException;

import org.eclipse.birt.report.model.api.HideRuleHandle;

import org.eclipse.birt.report.model.api.ReportDesignHandle;

import org.eclipse.birt.report.model.api.SessionHandle;

import org.eclipse.birt.report.model.api.TableHandle;

import org.eclipse.birt.report.model.api.activity.SemanticException ;

import org.eclipse.birt.report.model.api.elements.DesignChoiceConst ants;

import org.eclipse.birt.report.model.elements.ReportDesign;


import com.ibm.icu.util.ULocale;


public class ModifyReport {

static void modifyReport()throws IOException, SemanticException,
DesignFileException


{


ReportDesignHandle designHandle = null;

SessionHandle sessionHandle = null;

ReportDesign design = null;

DesignConfig dc = new DesignConfig();


dc.setConfigurationVariable("BIRT_HOME",
"C:\\birt-runtime-2.1RC2\\birt-runtime-2_1_0\\ReportEngine");

sessionHandle = new DesignEngine( dc ).newSessionHandle( ULocale.ENGLISH );




designHandle = sessionHandle.openDesign(
"c:\\test\\modifyreport\\customerdetail.rptdesign" );

design = (ReportDesign)designHandle.getModule( );


TableHandle table = (TableHandle) designHandle.findElement( "myTable" );


ColumnHandle column = (ColumnHandle)table.getColumns().get(2);


Iterator visibilities = column.visibilityRulesIterator( );


//only change the first

if ( visibilities.hasNext( ) )

{

HideRuleHandle ruleHandle = (HideRuleHandle) visibilities.next( );

ruleHandle.setFormat( DesignChoiceConstants.FORMAT_TYPE_ALL );

String expression = "true";

ruleHandle.setExpression(expression );


}






designHandle.save();

design.close( );

sessionHandle.closeAll(true);

System.out.println("Finished!");


}

public static void main(String[] args) {

try

{

modifyReport( );

}

catch ( Exception e )

{

e.printStackTrace();

}

}


}

"Barrera, German" <barrerager@delsatgroup.com> wrote in message
news:e4v6fm$tku$1@utils.eclipse.org...
> This works fine but I want to do this for every column in every report,
> thus
> i want to do this by code automatically. Also in my previous post I've
> confussed the requirement. I'v started asking how to include sorts
> dinamically an later I've asked how to hide columns, sorry for this
> confussion.
> We're planning to do several improvements to the web viewer so we need
> documentation and examples on how to modify the report design at runtime.
> We're having problems trying to figure out how to access and modify the
> diferent parts of the report design, such as filters, orders, colums,
> groups, totals, etc.
> Thank you.
>
> Barrera, German.
>
> "Jason Weathersby" <jweathersby@actuate.com> escribi
Previous Topic:Fonts in PDF
Next Topic:build BIRT from the command line
Goto Forum:
  


Current Time: Thu Sep 26 23:06:24 GMT 2024

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

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

Back to the top