Re: How make continous row index in dataTable

2010-05-11 Thread Erwin Bolwidt
Hi,

You can do it like this:

private private DefaultDataTableT dataTable;

// ...

new AbstractColumnWeekSchema(new ModelString(#)) {
public void populateItem(ItemICellPopulatorWeekSchema cellItem,
String componentId,
IModelWeekSchema 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: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: How make continous row index in dataTable

2010-05-11 Thread cleverpig
hi,Erwin!

Thank you so fast and accurate response!
That's great help to me!

2010/5/11 Erwin Bolwidt ebolw...@worldturner.nl

 Hi,

 You can do it like this:

 private private DefaultDataTableT dataTable;

 // ...

 new AbstractColumnWeekSchema(new ModelString(#)) {
 public void populateItem(ItemICellPopulatorWeekSchema cellItem,
 String componentId,
 IModelWeekSchema 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: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




--
cleverpig(Dan)
Location: Beijing
Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China
Zipcode: 100031
MSN: great_liu...@hotmail.com
QQ: 149291732
Skype: cleverpigatmatrix
Facebook ID:cleverpig
Blog: cleverpig.name/dan/
Tags: del.icio.us/cleverpig
Twitter: twitter.com/cleverpig
新浪微博: t.sina.com.cn/cleverpig
Organization: www.beijing-open-party.org
or...@facebook: http://www.facebook.com/group.php?gid=8159558294

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