Accessing row of datasource without subreport

0
Hi,
Answer is problably easy but... I've not found how to do this :(

From a Java app, I get a compliant JRDataSource object which contains fields (1 row, several fields). One of the fields is a JRDataSource too (for example SubElementsField) and it contains several rows and for each row several fields (for example SubElementField1).

Example
MainDataSource
--Field1 (String)
--Field2 (String)
--SubElementsField (JRDataSource)
-----SubElementField1

If I put a subreport in my main report with datasource SubElementsField, I can access in the subreport the field $F{SubElementField1} with this very easy syntax.

Now, what I want to do is to be able to access to SubElementField1 in my MAIN report through a syntax like $F{SubElementsField}[0]_F{SubElementField1}...

How can I do this... I don't want a sub-report, I just want to access the 3th field of the 1st row of SubElementsField in my main report (for example).

Which syntax can I use?
Thanks a lot.
olidel2003's picture
Joined: Nov 23 2006 - 12:58am
Last seen: 5 years 3 months ago

2 Answers:

0
Just create your own CustomDataSource and write your own public method that returns the fieldvalue of a given row number.

something like (just PseudoCode):

Code:
public Object getFieldValueByRowNumber(int rowNumber,String fieldName){<br />
<br />
  if (rowNumber>=0 && rowNumber <= datsource.getRecordCount() && fieldExist(fieldName){<br />
  return getRow(rowNumber).getFieldValue(fieldName);<br />
}<br />
}</td></tr></tbody></table><br />
<br />
quite easy (IMHO).<br />
<br />
regards + hth<br />
C-Box
C-Box's picture
1435
Joined: Jul 19 2006 - 5:58pm
Last seen: 26 min 42 sec ago
0
Thanks for the answer, I will do something like this.
olidel2003's picture
Joined: Nov 23 2006 - 12:58am
Last seen: 5 years 3 months ago
Feedback