Uploaded image for project: 'MyFaces Tomahawk'
  1. MyFaces Tomahawk
  2. TOMAHAWK-913

Layout of DataTable with groups + alternating rowStyles looks really bad

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Duplicate
    • 1.1.3, 1.1.5-SNAPSHOT
    • None
    • Extended Datatable
    • None

    Description

      Hi!

      I'm using Extended Data Tables and wanted to use the column's groupBy. Now all normal tables of this project have rowStyles with alternating row-background-colors, so I tried to apply them also on the grouped data. It looks really bad, since the generated row-span messes up the layout.

      The rowGroupStyle does not help - it's only useable as group separator style, therefor I think the name is a litte bit confusing - but that's another issue.

      I suggest, that the rowStyles should work on groups rather than on rows. Tried to patch HtmlTableRenderer accordingly and works fine for me:

      HtmlTableRenderer#createColumnInfos
      [..]
      int currentRowSpan=-1;
      int currentRowInfoIndex=-1;
      int groupCount = 0; // added by PP

      TableContext tableContext=htmlDataTable.getTableContext();
      [..]
      if(groupEndReached)

      { currentRowSpan=0; groupEndReached = false; groupCount++; // added by PP }

      rowInfo.setGroupIndex(groupCount); // added by PP
      tableContext.getRowInfos().add(rowInfo);

      HtmlTableRenderer#renderRowStyle
      String rowStyleClass;
      String rowStyle;
      if (uiData instanceof HtmlDataTable)
      {
      HtmlDataTable datatable = (HtmlDataTable) uiData;
      rowStyleClass = datatable.getRowStyleClass();
      rowStyle = datatable.getRowStyle();
      // added by PP
      TableContext tableContext = datatable.getTableContext();
      if (tableContext != null && tableContext.getRowInfos() != null && tableContext.getRowInfos().size() > rowStyleIndex)

      { RowInfo rowInfo = (RowInfo) tableContext.getRowInfos().get(rowStyleIndex); if (rowInfo.getGroupIndex() >= 0) rowStyleIndex = rowInfo.getGroupIndex(); }

      RowInfo added
      private int _groupIndex = -1;

      public int getGroupIndex()

      { return _groupIndex; }

      public void setGroupIndex(int groupIndex)

      { _groupIndex = groupIndex; }

      Attachments

        Activity

          People

            lu4242 Leonardo Uribe
            elite@chello.at Paul Palaszewski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: