HOWTO display elements in limited rows and cols?

0 views
Skip to first unread message

David Xiao

unread,
Dec 7, 2006, 10:33:20 AM12/7/06
to TurboGears
Hello there,

By using this:
hotitems = Items.select(orderBy='shortname')
I receive some results, records count could be 0~N, and next step i
want the HTML rendering this results in a 4x4 grid, means no more than
first 16 item will display. And if less than 16 item, the rest will be
empty in HTML.

How is the most neat code to do this? Actually I have tried some but
not working or buggy...

Regards
David

Diez B. Roggisch

unread,
Dec 7, 2006, 11:52:11 AM12/7/06
to turbo...@googlegroups.com
On Thursday 07 December 2006 16:33, David Xiao wrote:
> Hello there,
>
> By using this:
> hotitems = Items.select(orderBy='shortname')
> I receive some results, records count could be 0~N, and next step i
> want the HTML rendering this results in a 4x4 grid, means no more than
> first 16 item will display. And if less than 16 item, the rest will be
> empty in HTML.

Slicing?

<ul py:if="value[:4]" py:for="v in value[:4]">
<li py:content="v"/>
</ul>
<ul py:if="value[4:8]" py:for="v in value[4:8]">
<li py:content="v"/>
</ul>
...

and so on.
--
>> Diez B. Roggisch
>> Developer

T +49 (30) 443 50 99 - 27
F +49 (30) 443 50 99 - 99
M +49 (179) 11 75 303
E diez.r...@artnology.com


>> artnology GmbH

A Milastraße 4 / D-10437 Berlin
T +49 (30) 443 50 99 - 0
F +49 (30) 443 50 99 - 99
E in...@artnology.com
I http://www.artnology.com

Reply all
Reply to author
Forward
0 new messages