@pbreit
I tried your code,it did not work.It works for sorting by location. 
In models
db.define_table('listspace',
  Field('warehouse_location','string'),
  Field('warehouse_totalsize','string'),
  Field('contract_rent','string'))
In controller

def GetAllApprovedWarehouses():
    print request.vars.sort
    if request.vars.sort == 'size':
        order = db.listspace.warehouse_totalsize
    elif request.vars.sort == 'rent':
        order = db.listspace.contract_rent
    else:
        order = db.listspace.warehouse_location
    listSpaceRequests = db().select(db.listspace.ALL,orderby=order)
    return dict(listSpaceRequests=listSpaceRequests)


On Monday, July 4, 2016 at 5:26:55 AM UTC+5:30, pbreit wrote:
>
> We might need to see some of your code, specifically your models.
>
> Why do you have multiple tables?
>
> I could see you having one table called "property" such as:
>
> db.define_table('property',
>   Field('location'),
>   Field('size'),
>   Field('rent'))
>
> And then in your controller:
>
> def search():
>   if request.vars.orderby == 'size':
>     orderby = db.property.size
>   elif request.vars.orderby == 'rent':
>     orderby = db.property.rent
>   else:
>     orderby = db.property.location
>   properties = db(db.property.id>0).select(orderby=orderby)
>   return dict(properties=properties)
>
> Then a URL:
>
> http://mysite.com/search?orderby=rent
>
>
>
>
> On Saturday, July 2, 2016 at 4:36:17 AM UTC-7, pbt wrote:
>>
>> I am new to web2py .Thanks in advance. Please help me doing this. I have 
>> multiple tables with one record in each table as shown in the screenshot.I 
>> want to sort the tables using different parameters of the table. I want to 
>> keep a drop-down to sort records according to rent,size,location,etc...
>>
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to