You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Flavius <na...@silverlion.com> on 2008/06/05 19:55:28 UTC
Item.getIndex() on DefaultDataTable
I'm using a DefaultDataTable and I want to get the index of the selected
item. However the index always returns 0. Is this by design?
new AbstractColumn(new Model("Test Label"))
{
public void populateItem(Item item, String componentId, IModel model)
{
int selectedIndex = item.getIndex(); //this always returns 0;
}
}
However, with a dataView, I do get the item index:
dataView = new DataView("dataview", dp)
{
@Override
protected void populateItem(final Item item)
{
int selectedIndex = item.getIndex(); //increments by 1 with each
iteration.
}
}
I considered using a DataView instead of the DefaultDataTable, but the DDT
has the toolbars and such already nicely built in. Looking at the code, it
seems like an Item in a DataView represents the entire row
whereas in the DataGridView from the DefaultDataTable, it represents a cell.
Is this why the behavior
is different?
Thanks very much.
--
View this message in context: http://www.nabble.com/Item.getIndex%28%29-on-DefaultDataTable-tp17676006p17676006.html
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
Re: Item.getIndex() on DefaultDataTable
Posted by Maurice Marrink <ma...@gmail.com>.
On Thu, Jun 5, 2008 at 7:55 PM, Flavius <na...@silverlion.com> wrote:
>
> I'm using a DefaultDataTable and I want to get the index of the selected
> item. However the index always returns 0. Is this by design?
>
> new AbstractColumn(new Model("Test Label"))
> {
> public void populateItem(Item item, String componentId, IModel model)
> {
> int selectedIndex = item.getIndex(); //this always returns 0;
> }
> }
>
> However, with a dataView, I do get the item index:
>
> dataView = new DataView("dataview", dp)
> {
> @Override
> protected void populateItem(final Item item)
> {
> int selectedIndex = item.getIndex(); //increments by 1 with each
> iteration.
> }
> }
>
> I considered using a DataView instead of the DefaultDataTable, but the DDT
> has the toolbars and such already nicely built in. Looking at the code, it
> seems like an Item in a DataView represents the entire row
> whereas in the DataGridView from the DefaultDataTable, it represents a cell.
> Is this why the behavior
> is different?
Yes, inside the column you do not have access to the row index, only
to the column index. apparently this is your first column.
Maurice
>
> Thanks very much.
> --
> View this message in context: http://www.nabble.com/Item.getIndex%28%29-on-DefaultDataTable-tp17676006p17676006.html
> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org