Re: [web2py] SQLFORM.grid: sorting

2014-07-18 Thread Jacinto Parga
Hi, 

I solved it putting the foreing key format in the controller, before the 
grid:

def familia_manage():
*db.auth_user._format = '%(last_name)s %(first_name)s'*
fields=[db.t_familiares.f_nombre, 
db.t_familiares.f_apellidos,db.t_familiares.f_titular]
form = SQLFORM.grid(db.t_familiares, fields=fields )
return locals()

Where, in the table declaration:

db.t_familiares.f_titular.requires= 
(IS_IN_DB(db,'auth_user.id','%(last_name)s ''%(first_name)s'))

When I press the header I get it order by last_name instead of id.


El lunes, 21 de mayo de 2012 22:24:23 UTC+2, backseat escribió:

 Thanks Jim, I somehow missed the 'orderby' parameter to SQLFORM.grid 

 On Mon, 21 May 2012 13:11:31 -0700 (PDT), massimo@gmail.com 
 javascript: said: 

  foreign key. You can do a join. 

 Thanks Massimo; however, that's a little cryptic. Could you explain how a 
 join can be used to determine the sort order when I click on a 
 SQLFORM.grid header? 

 Thanks, 
 Keith 
 -- 
 You can have everything in life you want if you help enough other people 
 get what they want - Zig Ziglar. 

 Who did you help today? 


-- 
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/d/optout.


Re: [web2py] SQLFORM.grid: sorting

2014-07-18 Thread Massimo Di Pierro
You cannot a have an inner join in smartgrid. That's the biggest difference 
in this case. You can have orderby.





On Monday, 21 May 2012 15:47:53 UTC-5, Jim S wrote:

  Massimo - Is there a way to do it with a .smartgrid.  I know the question 
 wasn't on .smartgrid, but I'm using that extensively and too would like 
 some sort of solution.

 -Jim

 On 5/21/2012 3:11 PM, Massimo Di Pierro wrote: 

 foreign key. You can do a join.

 On Monday, 21 May 2012 14:49:06 UTC-5, Jim S wrote: 

 You can specify the sort order using the orderby parameter.  But, I 
 don't know how you get it to sort by the displayed value of a foreign 
 key column. 

 Ex: 

 orderby = [~db.asset.acquiredOn, db.asset.assetTag, db.asset.description] 

 ~ orders descending. 

  -Jim 

 On 5/21/2012 2:23 PM, Keith Edmunds wrote: 
  Two questions re SQLFORM.grid sorting. 
  
  1. Is it possible to specify the initial sort order? 
  
  2. I'm displaying a table that includes a foreign field. When I click 
 on 
  the header to sort by that field, it sorts by the field id rather than 
 by 
  the (displayed) foreign field. Can I sort by the displayed field? 
  
  Thanks, 
  Keith 

  

-- 
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/d/optout.


[web2py] SQLFORM.grid: sorting

2012-05-21 Thread Keith Edmunds
Two questions re SQLFORM.grid sorting.

1. Is it possible to specify the initial sort order? 

2. I'm displaying a table that includes a foreign field. When I click on
the header to sort by that field, it sorts by the field id rather than by
the (displayed) foreign field. Can I sort by the displayed field?

Thanks,
Keith
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] SQLFORM.grid: sorting

2012-05-21 Thread Jim Steil
You can specify the sort order using the orderby parameter.  But, I 
don't know how you get it to sort by the displayed value of a foreign 
key column.


Ex:

orderby = [~db.asset.acquiredOn, db.asset.assetTag, db.asset.description]

~ orders descending.

-Jim

On 5/21/2012 2:23 PM, Keith Edmunds wrote:

Two questions re SQLFORM.grid sorting.

1. Is it possible to specify the initial sort order?

2. I'm displaying a table that includes a foreign field. When I click on
the header to sort by that field, it sorts by the field id rather than by
the (displayed) foreign field. Can I sort by the displayed field?

Thanks,
Keith


Re: [web2py] SQLFORM.grid: sorting

2012-05-21 Thread Massimo Di Pierro
foreign key. You can do a join.

On Monday, 21 May 2012 14:49:06 UTC-5, Jim S wrote:

 You can specify the sort order using the orderby parameter.  But, I 
 don't know how you get it to sort by the displayed value of a foreign 
 key column. 

 Ex: 

 orderby = [~db.asset.acquiredOn, db.asset.assetTag, db.asset.description] 

 ~ orders descending. 

  -Jim 

 On 5/21/2012 2:23 PM, Keith Edmunds wrote: 
  Two questions re SQLFORM.grid sorting. 
  
  1. Is it possible to specify the initial sort order? 
  
  2. I'm displaying a table that includes a foreign field. When I click on 
  the header to sort by that field, it sorts by the field id rather than 
 by 
  the (displayed) foreign field. Can I sort by the displayed field? 
  
  Thanks, 
  Keith 



Re: [web2py] SQLFORM.grid: sorting

2012-05-21 Thread Keith Edmunds
Thanks Jim, I somehow missed the 'orderby' parameter to SQLFORM.grid

On Mon, 21 May 2012 13:11:31 -0700 (PDT), massimo.dipie...@gmail.com said:

 foreign key. You can do a join.

Thanks Massimo; however, that's a little cryptic. Could you explain how a
join can be used to determine the sort order when I click on a
SQLFORM.grid header?

Thanks,
Keith
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] SQLFORM.grid: sorting

2012-05-21 Thread Jim Steil
Massimo - Is there a way to do it with a .smartgrid.  I know the 
question wasn't on .smartgrid, but I'm using that extensively and too 
would like some sort of solution.


-Jim

On 5/21/2012 3:11 PM, Massimo Di Pierro wrote:

foreign key. You can do a join.

On Monday, 21 May 2012 14:49:06 UTC-5, Jim S wrote:

You can specify the sort order using the orderby parameter.  But, I
don't know how you get it to sort by the displayed value of a foreign
key column.

Ex:

orderby = [~db.asset.acquiredOn, db.asset.assetTag,
db.asset.description]

~ orders descending.

 -Jim

On 5/21/2012 2:23 PM, Keith Edmunds wrote:
 Two questions re SQLFORM.grid sorting.

 1. Is it possible to specify the initial sort order?

 2. I'm displaying a table that includes a foreign field. When I
click on
 the header to sort by that field, it sorts by the field id
rather than by
 the (displayed) foreign field. Can I sort by the displayed field?

 Thanks,
 Keith



Re: [web2py] SQLFORM.grid: sorting

2012-05-21 Thread Massimo Di Pierro
something like this?

SQLFORM.grid(db.table1.field1==db.table2.id,fields=db.table1.ALL,orderby=db.table2.field2)

smartgrid cannot do this.

On Monday, 21 May 2012 15:24:23 UTC-5, backseat wrote:

 Thanks Jim, I somehow missed the 'orderby' parameter to SQLFORM.grid 

 On Mon, 21 May 2012 13:11:31 -0700 (PDT), massimo.dipierro@gmail.comsaid: 

  foreign key. You can do a join. 

 Thanks Massimo; however, that's a little cryptic. Could you explain how a 
 join can be used to determine the sort order when I click on a 
 SQLFORM.grid header? 

 Thanks, 
 Keith 
 -- 
 You can have everything in life you want if you help enough other people 
 get what they want - Zig Ziglar. 

 Who did you help today? 



[web2py] SQLFORM.grid sorting dates

2011-10-27 Thread peter
If one clicks on 'data modified' in a windows folder, the files are
ordered with the most recent first.

In SQLFORM.grid if one has a column with a date in it, and one clicks
on the heading, they are sorted with the oldest first.

See www.ukjazz.net/store/albums

It would be nice if SQLFORM.grid acted the same as windows folders
here. Firstly for consistency, and secondly because usually one wants
to order things by the most recent first.

I realise that a second click on the heading does sort in this way

Peter