display only 20 entries in a table

31 views
Skip to first unread message

Iancic Bogdan

unread,
Aug 20, 2015, 6:30:58 AM8/20/15
to web2py-users
I have a lot of entries in the table that I want to display, and as i already have other things on the same page, i want to make this table show only 10-20 entries per page. How can I add that?

Here is the code I wrote in view:

    {{if prints:}}
    <h3>{{=T('Print history:')}}</h3>
    {{i=0}}
    <table>
        <thead>
                <th>#</th>
                <th>{{=T('Component name')}}</th>
                <th>{{=T('Component code')}}</th>
                <th>{{=T('Number of components')}}</th>
                <th>{{=T('Printing date')}}</th>
        </thead>
        <tbody>
            {{for design in prints:}}
                <tr><td>{{=i+1}}</td><td>         {{=design.fk_printhistory_componentcatalog.component_name}}</td><td>{{=design.fk_printhistory_componentcatalog.component_code}}</td><td>{{=design.no_of_components}}</td><td>{{=design.time_stamp}}</td></tr>
            {{i=i+1}}
            {{pass}}
        </tbody>
    </table>
    {{pass}}

Johann Spies

unread,
Aug 20, 2015, 8:30:47 AM8/20/15
to web...@googlegroups.com
Why do not limit your query to 10 or 20 items?

Regards
Johann

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

Iancic Bogdan

unread,
Aug 20, 2015, 8:34:47 AM8/20/15
to web2py-users
I want the user to see all the results, but they are too many to be shown on a single page. That's why i would like to share them on different pages

Iancic Bogdan

unread,
Aug 20, 2015, 8:34:55 AM8/20/15
to web2py-users
I want the user to see all the results, but they are too many to be shown on a single page. That's why i would like to share them on different pages

On Thursday, August 20, 2015 at 2:30:47 PM UTC+2, Johann Spies wrote:

Johann Spies

unread,
Aug 20, 2015, 8:40:17 AM8/20/15
to web...@googlegroups.com
You can either use SQLFORM.grid or use a technique explained in the book.  Search the book for 'pagination' and look in the results under "Other recipes".

Regards
Johann
Reply all
Reply to author
Forward
0 new messages