Hi Massimo, Thanks for suggesting this solution. I am now able to display a gird on my page with pagination and sorting options available. But whenever I click on page number or try to sort a column by clicking on its header, nothing happens. I get a blank page. I tried to debug it and found that when I click on any page number, post back takes place but form doesnt get validated(validation fails) and I do not get to see any grid. I am posting my code here. Please correct me if I have done anything wrong in it. def index(): result=None x=None searchform=SQLFORM.factory( Field('id', 'unicode',requires=empty_to_none), Field('account','unicode',requires=empty_to_none), Field('fromdate','unicode',requires=empty_to_none), Field('todate','unicode',requires=empty_to_none), Field('name','unicode',requires=empty_to_none), Field('status','integer'), Field('method',requires=IS_EMPTY_OR(IS_IN_SET(['Method1','Method2','Method3'], sort=True, zero='Select'))), Field('type','unicode',requires=IS_EMPTY_OR(IS_IN_SET(['Type1','Type2',], sort=True, zero='Select'))), Field('altname','unicode',requires=empty_to_none), Field('group','unicode',requires=IS_EMPTY_OR(IS_IN_SET(['Group1','Group2',], sort=True, zero='Select'))), Field('assignee','unicode',requires=empty_to_none), submit_button = 'Search' ) if searchform.accepts(request.vars,keepvalues=True): searchform.process() id=searchform.vars.id status=searchform.vars.status method=searchform.vars.method name=searchform.vars.name account=searchform.vars.account fromdate=searchform.vars.fromdate todate=searchform.vars.todate type=searchform.vars.type altname=searchform.vars.altname assignee=searchform.vars.assignee group=searchform.vars.group ##THIS METHOD RETURNS A LIST OF OBJECTS result=__get_objects(id, status, method, name, account, fromdate, todate, type, altname, assignee, group) ##THIS IS CODE TO CREATE IN MEMORY TEMPORARY DATABASE fields = [Field('ID'), Field('Method'), Field('Date'), Field('Status'), Field('Account'), Field('Name'), Field('Amount1'), Field('Amount2'), Field('Type') ]
temp_db = cache.ram('tmp_db',lambda: DAL('sqlite:memory').define_table('mytable',*fields)._db, None) temp_db.mytable.truncate() for obj in result['output']: temp_db.mytable.insert(ID=obj['id'], Method=obj['method'], Date=obj['date'], Status=obj['status'], Account=obj['account'], Name=obj['name'], Amount1=obj['amount1'], Amount2=obj['amount2'], Type=obj['type']) x = SQLFORM.grid(temp_db.mytable,create=False, deletable=False, editable=False, maxtextlength=64, paginate=2,searchable=False,details=False) else: response.flash = 'please fill the form' return dict(form=searchform,result=result,x=x) When postback happens due to any sorting or paging action, *searchform.accepts(request.vars,keepvalues=True) *fails and no grid gets displayed. Please help me to fix this. Thank you On Sunday, 8 September 2013 19:17:03 UTC+5:30, Massimo Di Pierro wrote: > You cannot unless you first load the data in a database. You can use a > temporary in memory database like this: > > fields = [Field('one'), Field('two'), Field('three'), ...] > temp_db = cache.ram('tmp_db',lambda: > DAL('sqlite:memory').define_table('mytable',*fields)._db, None) > > temp_db.mytable.truncate() > temp_db.mytable.insert(....) > form = SQLFORM.grid(temp_db.mytable) > > > On Sunday, 8 September 2013 05:35:13 UTC-5, Gliese 581 g wrote: >> >> Hi Massimo, >> I will try to be more specific. >> I am developing a web2py application(APP1) which works on the data which >> it gets from another web2py application(APP2). >> We do not have access to the database of APP2, we access their data >> through jsonrpc web services exposed by APP2. >> Now, there is an API(get_objects) of APP2 which gives us a list of >> certain type of objects. APP2 internally fetch this data from its database >> and convert it to a list of specific type of objects. >> I want it to be displayed in a table with sorting and paging >> capabilities. >> Can I use web2py's SQLFORM.grid to achieve this? >> Please suggest me any solution. >> >> Thank you. >> >> On Friday, 6 September 2013 20:26:54 UTC+5:30, Gliese 581 g wrote: >>> >>> ** >>> >>> I am working on a project where we have a different subsystem whose API >>> returns a list of certain type of objects. >>> >>> I want it to be displayed on my form. Can I use SQLForm.grid for this? >>> Please suggest. >>> >> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.