primefaces-extensions / primefaces-extensions.github.com

Organization repo, only for homepage, wiki and issue tracker
https://primefaces-extensions.github.io/
68 stars 22 forks source link

exporter error - expandableTable #204

Closed mrrgithub closed 10 years ago

mrrgithub commented 10 years ago

primefaces I'm exporting to pdf or excel the table used in showcase, exporter - expandable table and I notice that the information inside the p:rowexpansion changes between the html view and pdf or excel view. I notice that first item from datatable exports inside the data from the second item (it seems to mix up all data inside the p:rowexpansion on exported file). Thanks in advance.

ZeroIXI commented 10 years ago

Hi there, i had the same error too and just came to a solution that seems to work so far. Actually there is a code block in the Exporter Source that will explicitly ignore the first RowExpansion content from DataTable or DataList. The method "org.primefaces.extensions.component.exporter.Exporter.exportCells(DataTable table, Sheet sheet)" contains the following code;

if ( table.getRowIndex() == 0 ) {
            for (UIComponent component : table.getChildren()) {
                if ( component instanceof RowExpansion ) {
                    RowExpansion rowExpansion = (RowExpansion)component;
                    if ( rowExpansion.getChildren() != null ) {
                        if ( rowExpansion.getChildren().get(0) instanceof DataTable ) {
                            DataTable childTable = (DataTable)rowExpansion.getChildren().get(0);
                            childTable.setRowIndex(-1);
                        }
                        if ( rowExpansion.getChildren().get(0) instanceof DataList ) {
                            DataList childList = (DataList)rowExpansion.getChildren().get(0);
                            childList.setRowIndex(-1);
                        }
                    }

                }
            }
        }
        table.setRowIndex(table.getRowIndex() + 1);

Commenting this out, results in the right output given by the exporter.

sudheerj commented 10 years ago

Thanks for reporting.It is fixed now.

mrrgithub commented 10 years ago

Ok. Thanks for your support. Primefaces and PrimeFaces Extensions rocks!!!!