Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Version 4 (modified by anonymous, 13 years ago) (diff)


Ajax Grid Widget

This documentation is from Steve Bergman's post in  group

Using ajaxgrid is really quite simple. For future first-timers like me, here is an easy example which works with TG 0.9a4:

1. Quick start a project

2. Edit

Edit to look like the following:

import cherrypy
import turbogears
from turbogears import controllers, expose, redirect
from turbogears import identity
from turbogears.widgets import AjaxGrid
from datetime import datetime

grid = AjaxGrid(refresh_url="/search")

class Root(controllers.RootController):

  def index(self):
      return dict(form=grid)

  def search(self):

       # Fake a row of results
       date =
       hour = date.strftime('%H')
       minute = date.strftime('%M')
       second = date.strftime('%S')

       return dict(
           headers = ["Hour", "Minute", "Second"],
           rows = [[hour, minute, second]],

3. Create the template

Create the template "form.kid" and make it look like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" xmlns:py=""
  <meta content="text/html; charset=UTF-8" http-equiv="content-type"
  <title>Ajaxgrid Example</title>
    <span py:content="form.display()"></span>

4. Try it out

Start your project and try it out. You should get a single row with the current hour, minute, and second.

It should update when you click 'Update'.