0
Hi, I have a jTable
where the user defines which fields will appear on it, this way I would need several reports JasperReports
, one for each possible combination (chosen by jRadioButtons
).
There is a way to "send" the report fields(their names) beyond the parameters , without creating the fields previously in the report JasperReports
?
Print by Jtable:
Here’s the thing, there’s some jRadioButtons
where the user chooses which fields he wants to appear on jTable
(after the populated jTable), for example he may want to appear only "code" and "name".
Hence the need for several reports, with different fields, these fields I wanted to "send" and not have them created in the report in advance.
I’m trying something with DynamicReports
, but I wore a HQl
for the report containing the jTable
complete, without the user choosing what they want to view, I’m trying to adapt the code .
Method generating the report of jTable
complete:
private void jBGerarRelatorioActionPerformed(java.awt.event.ActionEvent evt) {
DefaultTableModel model = (DefaultTableModel) jTableResultado.getModel();
JRTableModelDataSource dataSource = new JRTableModelDataSource(model);
String path = getClass().getResource("/relatorios/Teste.jrxml").getPath();
JasperReport report = null;
try {
report = JasperCompileManager.compileReport(path);
} catch (JRException ex) {
Logger.getLogger(ConsultasView1.class.getName()).log(Level.SEVERE, null, ex);
}
Map<String, Object> parametros = new HashMap<String, Object>();
JasperPrint jp = null;
try {
jp = JasperFillManager.fillReport(report, parametros, dataSource);
} catch (JRException ex) {
Logger.getLogger(ConsultasView1.class.getName()).log(Level.SEVERE, null, ex);
}
JasperViewer jrv = new JasperViewer(jp, false);
jrv.setVisible(true);
}
Event of jRadioButton
private void jRadioCodigoItemStateChanged(java.awt.event.ItemEvent evt) {
if (evt.getStateChange() == ItemEvent.SELECTED) {
jTableResultado.getColumnExt("Código").setVisible(false);
} else if (evt.getStateChange() == ItemEvent.DESELECTED) {
jTableResultado.getColumnExt("Código").setVisible(true);
}
}
Is there any way you can get a print of your Jtable for me to visualize and better understand your problem? .
– Julio Cesar da Silva Barros
@Julio Cesar da Silva Barros, I added some information.
– Rodrigo
I decided to change the approach and did it with http://www.dynamicreports.org/ but if anyone knows anything about doing with
Jasperreports
, would like to try.– Rodrigo