Hello,
Here is the controller (default.py):
----------------------------------------------------------------------------------
def index():
response.files.append(URL(r=request,c='static/css/ui-darkness',f='jquery-ui-1.8.12.custom.css'))
response.files.append(URL(r=request,c='static/css',f='ui.jqgrid.css'))
response.files.append(URL(r=request,c='static/js',f='jquery-ui-1.8.12.custom.min.js'))
response.files.append(URL(r=request,c='static/src/i18n',f='grid.locale-en.js'))
response.files.append(URL(r=request,c='static/js',f='jquery.jqGrid.min.js'))
return dict()
def call():
"""
exposes services. for example:
http://..../[app]/default/call/jsonrpc
decorate with @services.jsonrpc the functions to expose
supports xml, json, xmlrpc, jsonrpc, amfrpc, rss, csv
"""
session.forget()
return service()
@service.json
def get_rows():
db.things.category.represent = lambda v: v.name
fields = ['id','name','category','price','owner']
rows = []
page = int(request.vars.page)
pagesize = int(request.vars.rows)
limitby = (page * pagesize - pagesize,page * pagesize)
orderby = db.things[request.vars.sidx]
if request.vars.sord == 'desc': orderby = ~orderby
for r in db(db.things.id>0).select(limitby=limitby,orderby=orderby):
vals = []
for f in fields:
rep = db.things[f].represent
if rep:
vals.append(rep(r[f]))
else:
vals.append(r[f])
rows.append(dict(id=r.id,cell=vals))
total = db(db.things.id>0).count()
pages = int(total/pagesize)
#if total % pagesize == 0: pages -= 1
data = dict(total=pages,page=page,rows=rows)
return data
==================================================================================
here is the view (default/index.html):
----------------------------------------------------------------------------------
====================================================================================
I have verified that the db.category and db.things table is indeed populated with dummy data.
This may be a dumb question - but i am new at javascript: What URL do I need to type into the browser to see the grid?
when I type in "http://127.0.0.1:8000/grid_example1/default/index", all I get is a blank screen
when I type in "", all I get is a message that says "Object does not exist"
0
rvquartz 13 years ago