| Issue 254: | Export only some columns | |
| 1 person starred this issue and may be notified of changes. | Back to list |
Hi!! I've a problem, and it's I can't export the columns I would like. My
JMesa show 4 columns (checkbox, date, headline and a priority number):
TableFacade tablefacade =
TableFacadeFactory.createTableFacade("jmesa_noticias", request);
tablefacade.setEditable(true);
tablefacade.setColumnProperties("checkbox", "fecha", "titular", "prioridad");
tablefacade.setItems(listado);
tablefacade.setExportTypes(response, ExportType.CSV,ExportType.JEXCEL,
ExportType.PDFP);
tablefacade.setStateAttr("restore");
BotonesJMesa botones = new BotonesJMesa();
botones.setGrupoAltaBajas(true);
BarraDeHerramientas toolbar = new BarraDeHerramientas();
toolbar.setBotones(botones);
tablefacade.setToolbar(toolbar);
HtmlComponentFactory factory = new
HtmlComponentFactory(tablefacade.getWebContext(),
tablefacade.getCoreContext());
HtmlTable table = factory.createTable();
HtmlRow row = factory.createRow();
row.setUniqueProperty("id");
HtmlColumn colCheck = factory.createColumn("checkbox");
colCheck.setTitle("<input type=\"checkbox\"
onclick=\"selectAllItems('jmesa_noticias')\"/>");
colCheck.getCellRenderer().setWorksheetEditor(new CheckboxWorksheetEditor());
colCheck.setFilterable(false);
colCheck.setSortable(false);
HtmlColumn colFecha = factory.createColumn("fecha");
colFecha.setTitle("Fecha");
colFecha.setEditable(false);
colFecha.getCellRenderer().setCellEditor(new DateCellEditor("dd/MM/yyyy"));
HtmlColumn colTitular = factory.createColumn("titular");
colTitular.setTitle("Titular");
colTitular.setEditable(false);
colTitular.setProperty("titular");
HtmlColumn colPrioridad = factory.createColumn("prioridad");
colPrioridad.setTitle("Prioridad");
colPrioridad.setEditable(false);
colPrioridad.setProperty("prioridad");
row.addColumn(colCheck);
row.addColumn(colFecha);
row.addColumn(colTitular);
row.addColumn(colPrioridad);
table.setRow(row); // be sure to set the row on the table
tablefacade.setTable(table);
Limit limit = tablefacade.getLimit();
if (limit.isExported()) {
tablefacade.render();
} else {
String html = tableFacade.render();
}
-----------------------
If I export it, the PDF document show the first column with the checkbox
code. I would like export the other columns, but not checkbox. I need the
checkbox column, but not in a PDF or Excel document.
Thanks so much!! ;)
Mar 10, 2010
Project Member
#1
jeff.johnston.mn@gmail.com
Mar 11, 2010
Thanks for you response!! I've followed your indications and it's OK!! ;) I've a new problem to export. Export to PDF is OK, but if I export to CSV or Excel, the cell with the information show it: "[td]....value1...[/td]" "[td]....value1...[/td]" (I don't use '<' because visually it can't modify this post ;D). So I found this reference: https://code.google.com/p/jmesa/wiki/Exports My problem is JMesa2.4.6 don`t exist ExcelComponentFactory. With CsvComponentFactory isn“t problem (the CSV export is right), but with Excel... This is my code: if (limit.isExported()) { if (limit.getExportType() == ExportType.JEXCEL) { ExcelComponentFactory factoryExcel = new ExcelComponentFactory(tablefacade.getWebContext(), tablefacade.getCoreContext()); Table table = factoryExcel.createTable(); Row row = factoryExcel.createRow(); Column col = factoryExcel.createColumn("fecha"); col.getCellRenderer().setCellEditor(new DateCellEditor("dd/MM/yyyy")); row.addColumn(col); col = factoryExcel.createColumn("titular"); row.addColumn(col); col = factoryExcel.createColumn("prioridad"); row.addColumn(col); table.setRow(row); // be sure to set the row on the table tablefacade.setTable(table); }else if (limit.getExportType() == ExportType.CSV) { CsvComponentFactory factoryCsv = new CsvComponentFactory(tablefacade.getWebContext(), tablefacade.getCoreContext()); Table table = factoryCsv.createTable(); Row row = factoryCsv.createRow(); Column col = factoryCsv.createColumn("fecha"); col.getCellRenderer().setCellEditor(new DateCellEditor("dd/MM/yyyy")); row.addColumn(col); col = factoryCsv.createColumn("titular"); row.addColumn(col); col = factoryCsv.createColumn("prioridad"); row.addColumn(col); table.setRow(row); // be sure to set the row on the table tablefacade.setTable(table); }else{ HtmlComponentFactory factory = new HtmlComponentFactory(tablefacade.getWebContext(), tablefacade.getCoreContext()); Table table = factory.createTable(); Row row = factory.createRow(); HtmlColumn col = factory.createColumn("fecha"); col.setEditable(false); col.getCellRenderer().setCellEditor(new DateCellEditor("dd/MM/yyyy")); row.addColumn(col); col = factory.createColumn("titular"); col.setEditable(false); row.addColumn(col); col = factory.createColumn("prioridad"); col.setEditable(false); row.addColumn(col); table.setRow(row); // be sure to set the row on the table tablefacade.setTable(table); } tablefacade.render(); } else { ..... } -------------- Excel exporting with HtmlComponentFactory is wrong too. ARRRRGGHH!! :D Any idea?? Thanks for your time and patience :D
Mar 11, 2010
Well... I changed my heavy code to this one, and it's all right for ever and ever!! :D
if (limit.isExported()) {
tablefacade.setColumnProperties("fecha", "titular", "prioridad");
Table table = tablefacade.getTable();
table.setCaption("Noticias");
Row row = table.getRow();
Column fecha = row.getColumn("fecha");
fecha.getCellRenderer().setCellEditor(new DateCellEditor("dd/MM/yyyy"));
tablefacade.render();
} else { ... }
Thanks so much!! I see you in another "ISSUES" XD
Apr 13, 2010
(No comment was entered for this change.)
Status:
Fixed
|