mnabeelkhan / tableexport-for-vaadin

Automatically exported from code.google.com/p/tableexport-for-vaadin
0 stars 0 forks source link

addDataRowRecursively bug #29

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. build hierarhical table with 3+ node deeps
1-
 2-
  3-
What is the expected output? What do you see instead?
Expected out
1-
 2-
  3-
Instead you will see only
1-
 3-
What version of the product are you using? On what operating system?
1.3 version addon. vaadin 6.8+

Please provide any additional information below.
Problem in addDataRowRecursively method. It is not include added nodes numbers 
for next child nodes.
  private int addDataRowRecursively(final Sheet sheetToAddTo, final Object rootItemId,
            final int row) {
        int numberAdded = 0;
        addDataRow(sheetToAddTo, rootItemId, row);
        numberAdded++;
        if (((Container.Hierarchical) getTable().getContainerDataSource()).hasChildren(rootItemId)) {
            final Collection<?> children =
                    ((Container.Hierarchical) getTable().getContainerDataSource())
                            .getChildren(rootItemId);
            for (final Object child : children) {
                numberAdded = numberAdded + addDataRowRecursively(sheetToAddTo, child, row+numberAdded);
            }
        }
        return numberAdded;
    }

Original issue reported on code.google.com by TrykovY...@gmail.com on 10 Aug 2012 at 2:58

GoogleCodeExporter commented 8 years ago
In addition I would move the grouping of the rows from method 
addHierarchicalDataRows to method addDataRowRecursively, that way all levels 
get grouped:

private int addDataRowRecursively(final Sheet sheetToAddTo, final Object 
rootItemId,
                            final int row) {
  int numberAdded = 0;
  addDataRow(sheetToAddTo, rootItemId, row);
  numberAdded++;
  if (((HierarchicalContainer) getTable().getContainerDataSource()).hasChildren(rootItemId)) {
    final Collection<?> children =
      ((HierarchicalContainer) getTable().getContainerDataSource())
        .getChildren(rootItemId);
    for (final Object child : children) {
      numberAdded = numberAdded + addDataRowRecursively(sheetToAddTo, child, row+numberAdded);
    }
    // grouping
    sheet.groupRow(row + 1, row+numberAdded-1);
    sheet.setRowGroupCollapsed(row + 1, true);
  }
  return numberAdded;
}

Original comment by petris...@googlemail.com on 23 May 2013 at 10:56