Reputation: 17
I would like to create datasets on demand by passing parameters to the report which are the names of the files that should be queried in order to get the right columns and data in the report, i was thinking of something like editing this.queryText attribute where "this" represents the dataset, which is not yet created then.
Is it possible and if so, how ?
Many thanks.
Upvotes: 1
Views: 1399
Reputation: 1081
You can always describe it using a scripted data set event adapter. The only issue is that content of the report will not know these names. You will need to write further code to handle that situation. If you create a blank report and add a scripted data source and a scripted dataset with no columns you can set the event handler to a class that looks like something similar to the following:
package my.event.handlers;
import org.eclipse.birt.report.engine.api.script.IScriptedDataSetMetaData;
import org.eclipse.birt.report.engine.api.script.IUpdatableDataSetRow;
import org.eclipse.birt.report.engine.api.script.eventadapter.ScriptedDataSetEventAdapter;
import org.eclipse.birt.report.engine.api.script.instance.IDataSetInstance;
public class MyScriptedDataSetMeta extends ScriptedDataSetEventAdapter {
private Integer cnt=0;
private Integer cntT=3;
@Override
public boolean fetch(IDataSetInstance dataSet, IUpdatableDataSetRow row) {
if( cnt < cntT){
try{
row.setColumnValue("col1", cnt);
row.setColumnValue("col2", "hello");
row.setColumnValue("A_Column", "jjj");
cnt++;
return true;
}catch (Exception e){
}
}
return false;
}
@Override
public boolean describe(IDataSetInstance dataSet,
IScriptedDataSetMetaData metaData) {
// TODO Auto-generated method stub
metaData.addColumn("col1", Integer.class);
metaData.addColumn("col2", String.class);
metaData.addColumn("A_Column", String.class);
return true;
}
}
Upvotes: 1