You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Clay Lehman <cl...@medfusion.net> on 2007/09/28 17:34:44 UTC

DataTable question

Hey everyone,

 

I am looking at examples on using DataTables and Repeaters, and I have a
question...

 

It looks like they insert default classes "headers" "even" and "odd"
into the table header and rows, but I was wondering if there is an easy
way for me to either set a property or create a subclass so that I can
use my own class names rather than these defaults?

 

Thanks in advance for any help!

 

-Clay

 


Re: DataTable question

Posted by Kent Tong <ke...@cpttm.org.mo>.

cblehman wrote:
> 
> It looks like they insert default classes "headers" "even" and "odd"
> into the table header and rows, but I was wondering if there is an easy
> way for me to either set a property or create a subclass so that I can
> use my own class names rather than these defaults?
> 

Try:

public class MyDataTable extends DataTable {
	public MyDataTable(String id, IColumn[] columns,
			ISortableDataProvider dataProvider, int rowsPerPage) {
		super(id, columns, dataProvider, rowsPerPage);
		addTopToolbar(new NavigationToolbar(this));
		addTopToolbar(new MyHeadersToolbar(this, dataProvider));
		addBottomToolbar(new NoRecordsToolbar(this));
	}
	protected Item newRowItem(String id, int index, IModel model) {
		Item item = super.newRowItem(id, index, model);
		item.add(new AttributeModifier("class", true, new Model(
				index % 2 == 0 ? "myEven" : "myOdd")));
		return item;
	}
}

public class MyHeadersToolbar extends HeadersToolbar {
	public MyHeadersToolbar(DataTable table, ISortStateLocator stateLocator) {
		super(table, stateLocator);
	}
}

MyHeadersToolbar.html:

&lt;wicket:panel&gt;
	&lt;tr class=\&quot;myHeaders\&quot;&gt;
		&lt;span wicket:id=\&quot;headers\&quot;&gt;
			&lt;th wicket:id=\&quot;header\&quot;&gt;&lt;span
wicket:id=\&quot;label\&quot;&gt;[header-label]&lt;/span&gt;&lt;/th&gt;
		&lt;/span&gt;
	&lt;/tr&gt;
&lt;/wicket:panel&gt;
-- 
View this message in context: http://www.nabble.com/DataTable-question-tf4535291.html#a12951941
Sent from the Wicket - User 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