Jump to content
Changes to the Jaspersoft community edition download ×

Again question on Clolumnnames...


Recommended Posts

By: Thomas Richter - hornet_f4c

Again question on Clolumnnames...

2002-11-13 09:37

I am using the JRTableDatasource. I understood I can access certain fields(columns) of my TableModel by defining appropriate report fields using the column names. Just as:

<field name="aName" class="java.lang.Object"/>

I guess, the Datasource uses the "getColumnName(int columnIndex)" method to identify the appropriate column in the given TableModel, right ?

 

Ok, as far as good. Now, if I don't know the name of my Columns, I still can access them by index. This is done by using a special convention within the Field declaration in the report xml. E.g.

<field name="COLUMN_0" class="java.lang.Object"/>

would mean I want to access the column with index 0. Nice ! This works as well.

But now I want to display this columns name in my report, too. Is there a way to do this ?

 

So can I call the "getColumnName(int index)" method of my TableModel from within JasperReports ? Or can JasperReports do that and provide the name of the Column ?

As shown in the first example, JR uses that method anyway, so it should be possible to provide the Columnname of a certain Column defined by index, shouldn't it ?

*Please say yes :)*

 

Thanks again !

 

 

 

 

 

 

By: Teodor Danciu - teodord

RE: Again question on Clolumnnames...

2002-11-13 13:46

 

Hi,

 

The supplied JRTableModelDataSource is supposed

to work very well in 80% cases.

It looks like you are in those 20%.

:)

 

This is why you should start implementing

your own version of such a data source in which

you could provide some code to deal with retrieving

the value for a special field called, let's say,

"ColumnName", that you're going to declare

in the report.

 

I think you got the idea.

Take a look at the "datasource" sample to see

how to implement custom data sources.

You'll be using code from the existing

JRTableModelDataSource class.

 

Good luck!

Teodor

 

 

 

 

 

By: Thomas Richter - hornet_f4c

RE: Again question on Clolumnnames...

2002-11-14 02:29

Yeah - Think I understand what you mean. Shouldn't be too difficult.

 

Thanx

 

 

 

 

By: Thomas Richter - hornet_f4c

RE: Again question on Clolumnnames...

2002-11-14 06:51

Btw, Why has it to be me, who is always amongst the 20 % ?? ;-)

 

However - the CustomDataSource does the Job, although I think that adressing the columnnames by special fields is not the best way to go.

But it works for now - I'll see how far I get this way.

 

Thanx !!!

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...