wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wicket_user_100 <wicket100u...@gmail.com>
Subject how to set width for DataTable (column) header.
Date Wed, 17 Jul 2013 14:56:01 GMT
Hi All,

I'm trying to set a width for a DataTable column:


List<IColumn&lt;Corpus, String>> ret = Lists.newArrayList();
ret.add(new AbstractColumn<Corpus, String>(new Model<>("")) {
            @Override
            public void populateItem(Item<ICellPopulator&lt;Corpus>>
cellItem, String componentId,
                                     IModel<Corpus> rowModel) {
                CheckBoxPanel checkBoxPanel = new
CheckBoxPanel(componentId);
                cellItem.add(checkBoxPanel);
                cellItem.add(new AttributeModifier("style", new
Model<String>("width:20px;")));
                selected.put(checkBoxPanel.getField(),
rowModel.getObject());
            }

            @Override
            public Component getHeader(String componentId) {
                Component header = super.getHeader(componentId);
                header.setRenderBodyOnly(true);
                header.add(new AttributeModifier("style", new
Model<String>("width:20px;")));
                return header;
            }
});

It doesn't work. I can see in result code:


	

			
			My cell title
	



	

			
			<div wicket:id="cell">
				<wicket:panel xmlns:wicket="http://wicket.apache.org">
					<input wicket:id="checkBox"
name="table:body:rows:1:cells:1:cell:checkBox" type="checkbox">
				</wicket:panel>
			</div>
		
			
			<div wicket:id="cell">My cell content</div>
		
	



I've tried also to add new AttributeModifier("style", new
Model<String>("width:20px;")) to the header in DataTable, see my code:

public class AjaxFallbackDataTable<T, S> extends DataTable<T, S> {
    private static final long serialVersionUID = 1L;

    public AjaxFallbackDataTable(String id, List<IColumn&lt;T, S>> columns,
ISortableDataProvider<T, S> dataProvider,
                                 int rowsPerPage) {
        super(id, columns, dataProvider, rowsPerPage);
        setOutputMarkupId(true);
        setVersioned(false);
        addTopToolbar(newAjaxNavigationToolbar());
        addTopToolbar(newAjaxFallbackHeadersToolbar(dataProvider));
        addBottomToolbar(new NoRecordsToolbar(this));
    }

    protected AjaxFallbackHeadersToolbar
newAjaxFallbackHeadersToolbar(ISortableDataProvider<T, S> dataProvider) {
        AjaxFallbackHeadersToolbar fb = new AjaxFallbackHeadersToolbar(this,
dataProvider);
        fb.add(new AttributeModifier("style", new
Model<String>("width:20px;")));
        return fb;
    }

    protected AjaxNavigationToolbar newAjaxNavigationToolbar() {
        AjaxNavigationToolbar fb = new AjaxNavigationToolbar(this);
        fb.add(new AttributeModifier("style", new
Model<String>("width:20px;")));
        return fb;
    }

    @Override
    protected Item<T> newRowItem(final String id, final int index, final
IModel<T> model) {
        return new OddEvenItem<T>(id, index, model);
    }
}

It doesn't work either. Can anybody write me - how can I set the
style="width:20px" for a Datatable column?
Thanks.




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/how-to-set-width-for-DataTable-column-header-tp4660310.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Mime
View raw message