Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.0.0-M1
    • Component/s: wicket-extensions
    • Labels:
      None
    • Environment:
      any

      Description

      Hi!

      I want to suggest an enhancement for the DataTable extension.

      Right now it's only possible to style columns (width, alignment, color etc.) via stylesheets. This has some not so nice implications IMHO:

      • You have to extend the IStyledColumn to return the proper CSS class.
      • You have to add a bunch of CSS classes to get the proper styles.
      • You have redundancy in HTML output - which isn't necessary.

      This is actually what <colgroup><col></colgroup> is meant to solve.

      My suggestion:

      Adding a 'addColGroup( ColGroup cg )'-feature, which actually lets you add x ColGroups with n Cols on which you can use AttributeModifiers to have your styles/classes/width-Attributes added.

      A quick implementation would be this:

      --[ColGroup.java]-
      import java.util.List;

      import org.apache.wicket.behavior.IBehavior;
      import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractToolbar;
      import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
      import org.apache.wicket.markup.html.WebMarkupContainer;
      import org.apache.wicket.markup.repeater.RepeatingView;

      public class ColGroup
      extends AbstractToolbar
      {
      private static final long serialVersionUID = 1L;

      private int numCols;
      private Col[] cols;

      public ColGroup( DataTable datatable, int numCols )

      { super( datatable ); this.numCols = numCols; }

      public void onBeforeRender()
      {
      if( !hasBeenRendered() )
      {
      WebMarkupContainer colgroup = new WebMarkupContainer( "colgroup" );
      for( IBehavior b : (List<IBehavior>) getBehaviors() )
      colgroup.add( b );
      setRenderBodyOnly( true );
      removeAll();
      add( colgroup );

      RepeatingView colgroupCols = new RepeatingView( "elements" );
      colgroup.add( colgroupCols );

      for( Col column : getCols() )

      { WebMarkupContainer item = new WebMarkupContainer( colgroupCols.newChildId() ); colgroupCols.add( item ); item.add( column ); }

      }
      super.onBeforeRender();
      }

      public final Col[] getCols( )
      {
      if( cols == null )

      { cols = new Col[numCols]; for( int i = 0; i < numCols; i++ ) cols[i] = new Col(); }

      return(cols);
      }

      public final class Col
      extends WebMarkupContainer
      {
      private static final long serialVersionUID = 1L;

      private Col()

      { super( "col" ); }

      }

      }
      --[/ColGroup.java]-

      --[ColGroup.html]-
      <wicket:panel>
      <colgroup wicket:id="colgroup">
      <wicket:container wicket:id="elements"><col wicket:id="col"/></wicket:container>
      </colgroup>
      </wicket:panel>
      --[/ColGroup.html]-

      Usage:

      ColGroup colgroup = new ColGroup( datatable, 4 );
      colgroup.add( new SimpleAttributeModifier( "style", "border: solid 1px green;" ) );
      Col[] cols = colgroup.getCols();
      cols[0].add( new SimpleAttributeModifier( "width", "10%" ) );
      cols[1].add( new SimpleAttributeModifier( "width", "35%" ) );
      cols[2].add( new SimpleAttributeModifier( "width", "45%" ) );
      cols[3].add( new SimpleAttributeModifier( "width", "10%" ) );
      datatable.addColGroup( colgroup );

      Any thoughts?

      Regards, — Jan.

        Activity

        Jan Kriesten created issue -
        Hide
        Igor Vaynberg added a comment -

        matej, you said we might want to put this in? even though it doesnt always work in mozilla browsers as pointed out on the list?

        Show
        Igor Vaynberg added a comment - matej, you said we might want to put this in? even though it doesnt always work in mozilla browsers as pointed out on the list?
        Igor Vaynberg made changes -
        Field Original Value New Value
        Assignee Matej Knopp [ knopp ]
        Hide
        Eelco Hillenius added a comment -

        Assigned version (beta 4)

        Show
        Eelco Hillenius added a comment - Assigned version (beta 4)
        Eelco Hillenius made changes -
        Fix Version/s 1.3.0-beta5 [ 12312818 ]
        Hide
        Matej Knopp added a comment -

        Postponing as this should not delay the 1.3 release

        Show
        Matej Knopp added a comment - Postponing as this should not delay the 1.3 release
        Matej Knopp made changes -
        Fix Version/s 1.4.0-alpha [ 12312523 ]
        Fix Version/s 1.3.0-beta5 [ 12312818 ]
        Matej Knopp made changes -
        Priority Major [ 3 ] Minor [ 4 ]
        Frank Bille Jensen made changes -
        Fix Version/s 1.4-M1 [ 12312523 ]
        Fix Version/s 1.4-M2 [ 12312911 ]
        Frank Bille Jensen made changes -
        Fix Version/s 1.4-M3 [ 12312912 ]
        Fix Version/s 1.4-M2 [ 12312911 ]
        Hide
        Martijn Dashorst added a comment -

        Moved to next milestone release.

        Show
        Martijn Dashorst added a comment - Moved to next milestone release.
        Martijn Dashorst made changes -
        Fix Version/s 1.4-M3 [ 12312912 ]
        Fix Version/s 1.4-M4 [ 12313295 ]
        Hide
        Igor Vaynberg added a comment -

        move new features to 1.5

        Show
        Igor Vaynberg added a comment - move new features to 1.5
        Igor Vaynberg made changes -
        Fix Version/s 1.5-M1 [ 12313078 ]
        Fix Version/s 1.4-M4 [ 12313295 ]
        Igor Vaynberg made changes -
        Fix Version/s 1.5-M2 [ 12315237 ]
        Fix Version/s 1.5-M1 [ 12313078 ]
        Igor Vaynberg made changes -
        Fix Version/s 1.5-M3 [ 12315329 ]
        Fix Version/s 1.5-M2 [ 12315237 ]
        Jeremy Thomerson made changes -
        Fix Version/s 1.5-M4 [ 12315483 ]
        Fix Version/s 1.5-M3 [ 12315329 ]
        Martin Grigorov made changes -
        Fix Version/s 1.5-M4 [ 12315483 ]
        Martin Grigorov made changes -
        Assignee Matej Knopp [ knopp ] Martin Grigorov [ mgrigorov ]
        Martin Grigorov made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 7.0.0 [ 12322958 ]
        Resolution Fixed [ 1 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        2322d 1h 23m 1 Martin Grigorov 20/Feb/14 13:21

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            Jan Kriesten
          • Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development