hiding a column in smartgrid

627 views
Skip to first unread message

Ricardo Cárdenas

unread,
May 27, 2013, 11:57:31 AM5/27/13
to web...@googlegroups.com
Hi,

My model contains a URL field, and I'm displaying the model in a SQLFORM.smartgrid. I don't want to show the whole URL, but I do want the user to be able to visit the URL directly from the grid. So I use the 'links' parameter to SQLFORM.smartgrid. It works very nicely:

links=[dict(header="Link", body=lambda row: A("Go", _href=row.linkfield, _target="_blank"))]

But it doesn't work if I remove 'linkfield' from the 'fields' parameter to SQLFORM.smartgrid. That's because, according to the documentation:

'fields' is a list of fields to be fetched from the database. It is also used to determine which fields to be shown in the grid view.

In my use case, I want the field to be fetched, but not shown. Is there a "smart" (pun intended :) way to do this?

best regards -Ricardo

ps. I'd prefer not to mess around with jquery, and anyway it seems the <th> does not have a CSS class or id that would allow me to hide an undesired column.

Calvin

unread,
May 27, 2013, 2:21:34 PM5/27/13
to web...@googlegroups.com
before the call to SQLFORM.smartgrid, add

db.tablename.linkfield.readable=False

Ricardo Cárdenas

unread,
May 27, 2013, 4:16:43 PM5/27/13
to web...@googlegroups.com
Thanks Calvin! Exactly what I needed.

Is there be a way to hide it at the grid level, but let it be readable when viewing the record detail? (I can do without it -- just curious really.) best regards


--
 
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/wKKlDWIuA3U/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
 Ricardo Cárdenas | http://alum.mit.edu/www/rcardenas | Perú: (+51) 96176-3092 | USA: +1 650 395-7772 | México: +52 (155) 2691-9958
Reply all
Reply to author
Forward
0 new messages