TurboGears Tutorial
TurboGears Useful Resources
Selected Reading
- TurboGears - Deployment
- TurboGears - Restful Applications
- TurboGears - Pluggable Applications
- TurboGears - Writing Extensions
- TurboGears - Hooks
- TurboGears - Scaffolding
- TurboGears - Using MongoDB
- Authorization & Authentication
- TurboGears - Admin Access
- TurboGears - Pagination
- TurboGears - DataGrid
- TurboGears - Crud Operations
- TurboGears - Creating Models
- TurboGears - Sqlalchemy
- TurboGears - Caching
- TurboGears - Cookies and Sessions
- TurboGears - Flash Messages
- TurboGears - Validation
- TurboGears - Toscawidgets Forms
- TurboGears - URL Hierarchy
- TurboGears - JSON Rendering
- TurboGears - Includes
- Genshi Template Language
- TurboGears - HTTP Methods
- TurboGears - Serving Templates
- TurboGears - Dependencies
- TurboGears - First Program
- TurboGears - Environment
- TurboGears - Overview
- TurboGears - Home
TurboGears Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
TurboGears - DataGrid
TurboGears – DataGrid
The ToscaWidgets contains a DataGrid control which provides a quick way to present data in tabular form. The DataGrid object is declared as follows −
from tw2.forms import DataGrid student_grid = DataGrid(fields = [( Name , name ),( City , city ), ( Address , address ), ( PINCODE , pincode )])
Now, showgrid() function retrieves all the records in student table and exposes the data to grid.html template. First the code for showgrid() function and then grid.html code is given below −
showgrid()
@expose( hello.templates.grid ) def showgrid(self): data = DBSession.query(student).all() return dict(page = grid , grid = student_grid, data = data)
grid.html
<!DOCTYPE html> <html xmlns = "http://www.w3.org/1999/xhtml" xmlns:py = "http://genshi.edgewall.org/" lang = "en"> <head> <title>Student Registration Form</title> </head> <body> <span id = "getting_started"> <span>${grid.display(value = data)}</span> </span> </body> </html>
The following tabular data will be displayed when http://localhost:8080/showpst URL is entered in the browser −
Advertisements