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

Changes between Version 4 and Version 5 of AjaxGrid


Ignore:
Timestamp:
02/01/07 00:18:31 (12 years ago)
Author:
jorge.vargas
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AjaxGrid

    v4 v5  
    1 = Ajax Grid Widget = 
    2  
    3 This documentation is from Steve Bergman's post in [http://groups.google.com/group/turbogears/browse_thread/thread/fb6c3611b49af727/3d4d4ad72610b638#3d4d4ad72610b638 group] 
    4  
    5  
    6 Using ajaxgrid is really quite simple.  For future first-timers like 
    7 me, here is an easy example which works with TG 0.9a4: 
    8  
    9 == 1. Quick start a project == 
    10  
    11  
    12 == 2. Edit controllers.py == 
    13 Edit controllers.py to look like the following: 
    14  
    151{{{ 
    16 #!python 
    17 import cherrypy 
    18 import turbogears 
    19 from turbogears import controllers, expose, redirect 
    20 from turbogears import identity 
    21 from turbogears.widgets import AjaxGrid 
    22 from datetime import datetime 
    23  
    24 grid = AjaxGrid(refresh_url="/search") 
    25  
    26 class Root(controllers.RootController): 
    27  
    28   @expose(template=".templates.form") 
    29   def index(self): 
    30       return dict(form=grid) 
    31  
    32   @expose(format="json") 
    33   def search(self): 
    34  
    35        # Fake a row of results 
    36        date = datetime.today() 
    37        hour = date.strftime('%H') 
    38        minute = date.strftime('%M') 
    39        second = date.strftime('%S') 
    40  
    41        return dict( 
    42            headers = ["Hour", "Minute", "Second"], 
    43            rows = [[hour, minute, second]], 
    44   ) 
     2#!NewsFlash 
     3This wiki page has been migrated to the new docs site currently at  
     4http://docs.turbogears.org/1.0/AjaxGrid 
    455}}} 
    46  
    47 == 3. Create the template == 
    48 Create the template "form.kid" and make it look like this:  
    49  
    50 {{{ 
    51 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    52 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#" 
    53     py:extends="'master.kid'"> 
    54 <head> 
    55   <meta content="text/html; charset=UTF-8" http-equiv="content-type" 
    56 py:replace="''"/> 
    57   <title>Ajaxgrid Example</title> 
    58 </head> 
    59   <body> 
    60     <span py:content="form.display()"></span> 
    61   </body> 
    62 </html> 
    63 }}} 
    64  
    65 == 4. Try it out == 
    66 Start your project and try it out.  You should get a single row with 
    67 the current hour, minute, and second.   
    68  
    69 It should update when you click 'Update'.  
    70  
    71