I just pushed some changes to the new py4web grid (aka mtable aka
publisher). It requires the latest pydal.
There is an example in http://127.0.0.1:8000/examples
But as of today it works like this:
0) make sure you have
apps/{yourapp}/static/components/mtable.js and mtable.html (copy them from
_dashboard)
1) in controller define a publisher:
from py4web.utils.publisher import Publisher
publisher = Publisher(db, policy=ALLOW_ALL_POLICY)
# you can set more complex policies using the pydal restapi policy format.
If the policy requires a logger in user do:
publisher = Publisher(db, auth=auth.user, policy=ALLOW_ALL_POLICY)
2) in the action:
# exposed as
/examples/grid
@action('mygrid')
@action.uses('mygrid.html')
def example_grid():
return dict(grid=publisher.grid(db.mytablename)) ### <<< your table name
3) In mygrid.html all you need is
[[extends "layout.html"]]
[[=grid]]
Notice you can have multiple grids per page. You can also have multiple
publishers if you need different policies for different grids but you
probably can do everything with one publisher. Each publisher exposes its
own RESTAPI.
Does it work? Suggestions for improvements?
--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/f992be50-9969-4e32-87fb-af9549bdaf57%40googlegroups.com.