If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!


  • 0
    tomyblack  14 years ago
    Hi again, I can now edit but add and delete button doesn't work. What am I doing wrong or what's missing ? ------------ Controller: ------------
    @service.json    
    def getjson(): 
        page=int((request.vars.page)) 
        limit=int((request.vars.rows)) 
        rcount=db(db.things.id>0).count() 
        total_pages=int(ceil(rcount*1.0/limit)) 
        start = limit*page-limit 
        records = db(db.things.id>0).select(limitby=(start,start+limit)) 
        cellist=[] 
        mylist={} 
        mylist['total']=str(total_pages) 
        mylist['page']=str(page) 
        mylist['records']=str(rcount) 
        for row in records: 
            temp={} 
            temp['id']=str(row.id) 
            temp['cell']=[row.id,row.name,row.category,row.price,row.owner] 
            cellist=cellist+[temp] 
            mylist['rows']=cellist 
        return(mylist) 
    
    
    @service.json
    def setjson(): 
        value=request.vars
        id=value['id'] 
        name=value['name'] 
        category=value['category'] 
        price=value['price'] 
        owner=value['owner'] 
        db(db.things.id==id).update(name=name, category=category, price=price, owner=owner)
    
    ------------------------ View.html ------------------------
    {{extend 'layout.html'}}