Hi,
You can do it like this:
private private DefaultDataTable<T> dataTable;
// ...
new AbstractColumn<WeekSchema>(new Model<String>("#")) {
public void populateItem(Item<ICellPopulator<WeekSchema>> cellItem,
String componentId,
IModel<WeekSchema> rowModel) {
Item<?> item = (Item<?>) cellItem.getParent().getParent();
int index = dataTable.getCurrentPage() * dataTable.getRowsPerPage() +
item.getIndex() + 1;
cellItem.add(new Label(componentId, String.valueOf(index)));
}
}
Regards,
Erwin Bolwidt
On 5/11/10 9:56 AM, cleverpig wrote:
> hi,everybody!
>
> I used this way to build dataTable:
> DataProvider+Column defines+DataTable.
>
> I want to add a index column at the first column,and hope that keeping
> continuous index number.
> So whenever turn to another page it will hold continuously,just not
> renew from 1.
>
> But now,I can get a sample code to implement index number in each
> page,not ontinuous index number yet.
>
> IColumn[] columns={
> new AbstractColumn(new ResourceModel("column.index")){
>
> private static final long serialVersionUID = 0L;
>
> @Override
> public void populateItem(Item cellItem, String
> componentId, IModel
> rowModel) {
> Item
> item=(Item)cellItem.getParent().getParent();
> cellItem.add(new Label(componentId,new
> Model(item.getIndex()+1)));
> }
> },
> ...
> };
>
> DataTable dataTable=new DataTable("entries",columns,dataProvider,5);
> ...
>
> How to make continous row index in dataTable? Hoping that the wise
> friend to help me.
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]