Discussion:
How to display a grid with empty cells
Alec Swan
2012-08-09 02:56:50 UTC
Permalink
Hello,

I am using Wicket 1.4.17 and need to display a 3x3 table with all of
its cells, some of which may not have a model and hence blank. So, if
my DataProvider returns 0 elements than I want all 9 cells to be shown
as blank.

I started using GridView and overrode its populateEmptyItem() method
to display empty cells. However, contrary to its JavaDoc "Add
component to an Item for which there is no model anymore and is shown
in a cell" this method is not being called unless a row has at least
one item (see GrdiView#addItems()).

What would the easiest way to accomplish what I need without copying
the entire code from GridView class? Any other component that can do
that?

Thanks,

Alec

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Bertrand Guay-Paquet
2012-08-09 03:37:15 UTC
Permalink
Hi,

I haven't used the GridView directly so I can't help you with it
specifically. However, have you considered modifying your provider to
always return 9 records with some having an empty placeholder? It's
definitely a "hack", but it may be worth a try.

Bertrand
Post by Alec Swan
Hello,
I am using Wicket 1.4.17 and need to display a 3x3 table with all of
its cells, some of which may not have a model and hence blank. So, if
my DataProvider returns 0 elements than I want all 9 cells to be shown
as blank.
I started using GridView and overrode its populateEmptyItem() method
to display empty cells. However, contrary to its JavaDoc "Add
component to an Item for which there is no model anymore and is shown
in a cell" this method is not being called unless a row has at least
one item (see GrdiView#addItems()).
What would the easiest way to accomplish what I need without copying
the entire code from GridView class? Any other component that can do
that?
Thanks,
Alec
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Paul Bors
2012-08-09 14:39:52 UTC
Permalink
Make use of the EmptyPanel class for the null or empty models. You could
also simply call setVisible(false) on your component if you can hide it all
together.

http://wicket.apache.org/apidocs/1.4/org/apache/wicket/markup/html/panel/Emp
tyPanel.html

~ Thank you,
Paul Bors

-----Original Message-----
From: Bertrand Guay-Paquet [mailto:***@step.polymtl.ca]
Sent: Wednesday, August 08, 2012 11:37 PM
To: ***@wicket.apache.org
Subject: Re: How to display a grid with empty cells

Hi,

I haven't used the GridView directly so I can't help you with it
specifically. However, have you considered modifying your provider to always
return 9 records with some having an empty placeholder? It's definitely a
"hack", but it may be worth a try.

Bertrand
Post by Alec Swan
Hello,
I am using Wicket 1.4.17 and need to display a 3x3 table with all of
its cells, some of which may not have a model and hence blank. So, if
my DataProvider returns 0 elements than I want all 9 cells to be shown
as blank.
I started using GridView and overrode its populateEmptyItem() method
to display empty cells. However, contrary to its JavaDoc "Add
component to an Item for which there is no model anymore and is shown
in a cell" this method is not being called unless a row has at least
one item (see GrdiView#addItems()).
What would the easiest way to accomplish what I need without copying
the entire code from GridView class? Any other component that can do
that?
Thanks,
Alec
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Alec Swan
2012-08-09 15:17:50 UTC
Permalink
I tried returning nulls for blank items from data provider but as you
said it feels like a hack because now my GridView#populateItem()
needs to handle items with null model objects.

The way GridView behaves is confusing because it displays the entire
row of cells (some potentially blank) if the row has at least one
item. If the row has no items, then the row is not displayed. So,
GridView pads every row with empty cells but doesn't do this for every
column.

Should this be filed as a bug?

On Wed, Aug 8, 2012 at 9:37 PM, Bertrand Guay-Paquet
Post by Bertrand Guay-Paquet
Hi,
I haven't used the GridView directly so I can't help you with it
specifically. However, have you considered modifying your provider to always
return 9 records with some having an empty placeholder? It's definitely a
"hack", but it may be worth a try.
Bertrand
Post by Alec Swan
Hello,
I am using Wicket 1.4.17 and need to display a 3x3 table with all of
its cells, some of which may not have a model and hence blank. So, if
my DataProvider returns 0 elements than I want all 9 cells to be shown
as blank.
I started using GridView and overrode its populateEmptyItem() method
to display empty cells. However, contrary to its JavaDoc "Add
component to an Item for which there is no model anymore and is shown
in a cell" this method is not being called unless a row has at least
one item (see GrdiView#addItems()).
What would the easiest way to accomplish what I need without copying
the entire code from GridView class? Any other component that can do
that?
Thanks,
Alec
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org

Loading...