theohoekstra Posted January 7, 2010 Share Posted January 7, 2010 Hi,I have a report with a subreport, and the filterexpression of the subreport is defined in a field of the parent's dataset (as a String). My datasources are CSV datasources.Is there a way to set/compile/evaluate the filterexpression of the subreport at runtime?Thanks!Post Edited by theohoekstra at 01/07/2010 12:05 Link to comment Share on other sites More sharing options...
zizul Posted January 7, 2010 Share Posted January 7, 2010 Hi.You can pass that field from parent report to subreport as parameter. Than use this parameter in subreport as a datasource filter expression regards,Kacper Link to comment Share on other sites More sharing options...
theohoekstra Posted January 7, 2010 Author Share Posted January 7, 2010 Hi Kacper,Thanks for your reply.My 'problem' is that I have my filter expression as a string, for example"new Boolean($F{field1}.startsWith(\"Am\"))". I can pass this as a parameter to the subreport, and fill the filterExpression with this parameter, but it is a String (and not a Boolean).The subreport should be filled using different filters for example:"new Boolean($F{field1}.startsWith(\"Am\"))""new Boolean($F{field2}.equals(\"To\"))"And these filters are defined in a field of the parent report's dataset.Somehow, I need the filter string to be converted to an expression, and insert it to the JRFillDataset instance handling the datasource.Best regards,Theo Link to comment Share on other sites More sharing options...
lucianc Posted January 12, 2010 Share Posted January 12, 2010 One solution is to dynamically alter the subreport template at fill time by setting the filter expression, and then compiling the subreport in order to use it.Or theoretically you could use a Java interpreter such as Grovvy or BeanShell to evaluate the expression. But that wouldn't be straightforward either.Regards,Lucian Link to comment Share on other sites More sharing options...
theohoekstra Posted January 14, 2010 Author Share Posted January 14, 2010 Hello Lucian,Thanks for the suggested solutions. The interpreter or jrxml alteration crossed my mind, but I wanted to be sure there was no easier solution I had overlooked.I now solved my problem by splitting my csv files by a preprocessor, and dynamically creating a new csv datasource for the specific file I need for the subreport.Thanks, best regards,Theo Hoekstra Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now