Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-3678

GridView to fill columns first (top-down, then left-right)

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.4.17
    • None
    • wicket
    • None

    Description

      GridView fills the table by rows. Filling by columns is needed too.

      Since it uses DataProvider's iterator and by nature of HTML tables, the data need to come in the order of row's cells,
      the best approach I've found is to reorder the list appropriately.

         private void recalculateList2() {
            int cols = this.getColumns();
            // Column height.
            int colHeight = list.size() / cols;
            // Last items may not fit whole row.
            colHeight += ( (list.size() % cols) == 0 ? 0 : 1 );
            
            list2 = new ArrayList<T>( list );
            for ( int i = 0; i < list.size(); i++ ) {
               int newIndex = (i % colHeight) * cols + (i / colHeight);
               list2.set( newIndex, list.get(i) );
            }
         }
      

      Computing the right position in a custom Iterator might be even better - no need for an extra ArrayList.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              pekarna Ondra Žižka
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: