I like to share the code snippet in converting JqGrid in Php to JqGrid in Web2py.
1. You need to installed Firebug in FireFox to check for error, if you see blank screen. 2. You need to install the css style sheet and right javascripts in the static directory of your application The controller code: --------------------------- from math import ceil def index(): return dict(message=T('Hello World')) def myedit(): return dict() def getjson(): page=int((request.vars.page)) limit=int((request.vars.rows)) rcount=db(db.invoice.id>0).count() total_pages=int(ceil(rcount*1.0/limit)) start=limit*page-limit records=db(db.invoice.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.invid,row.invdate,row.name,row.amount,row.tax,row.total,row.note] cellist=cellist+[temp] mylist['rows']=cellist return(mylist) def setjson(): value=request.vars id=value['id'] name=value['name'] amount=value['amount'] tax=value['tax'] total=value['total'] note=value['note'] db(db.invoice.id==id).update (name=name,amount=amount,tax=tax,total=total,note=note) myedit.html ---------------- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{{=T.accepted_language or 'en'}}"> <head> <title>{{=response.title or 'response.title'}}</title> <link href="{{=URL(r=request,c='static',f='css/ui-lightness/jquery- ui-1.7.2.custom.css')}}" rel="stylesheet" type="text/css" media="screen" /> <link href="{{=URL(r=request,c='static',f='css/ui.jqgrid.css')}}" rel="stylesheet" type="text/css" media="screen" /> <script src="{{=URL(r=request,c='static',f='js/jquery-1.3.2.min.js')}}" type="text/javascript"></script> <script src="{{=URL(r=request,c='static',f='js/i18n/grid.locale-en.js')}}" type="text/javascript"></script> <script src="{{=URL(r=request,c='static',f='js/jquery.jqGrid.min.js')}}" type="text/javascript"></script> <script type="text/javascript"> jQuery(document).ready(function(){ var last; jQuery("#list").jqGrid({ url:'/jqGrid/default/getjson.json', datatype: 'json', mtype: 'GET', height: 250, colNames:['Id','Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55,editable:false,editoptions: {readonly:true,size:10},hidden:true}, {name:'invno',index:'invno', width: 80,editable:true,editoptions:{readonly:true,size:10}}, {name:'invdate',index:'invdate', width: 80,editable:true,editoptions:{size:10}}, {name:'name',index:'name', width:90,editable:true,editoptions: {size:25}}, {name:'amount',index:'amount', width:60, align:"right",editable:true,editoptions:{size:10}}, {name:'tax',index:'tax', width:60, align:"right",editable:true,editoptions:{size:10}}, {name:'total',index:'total', width: 60,align:"right",editable:true,editoptions:{size:10}}, {name:'note',index:'note', width:100, sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"2",cols:"20"}} ], editurl:'/jqGrid/default/setjson', pager: jQuery('#pager'), rowNum:10, rowList:[10,15], sortname: 'id', sortorder: "desc", viewrecords: true, imgpath:'/jqGrid/static/css/ui-lightness/images', caption:'My editable grid' }); $("#bedata").click(function(){ var gr = jQuery("#list").getGridParam ('selrow'); if( gr != null ) jQuery("#list").editGridRow(gr,{height: 280,reloadAfterSubmit:false}); else alert("Please Select Row");; }); }); </script> </head> <body> <table id="list" class="scroll" style="center;"></table> <div id="pager" class="scroll" style="text-align:center;"></div> <input type="BUTTON" id="bedata" value="Edit Selected" /> </body> </html> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---