[web2py] Re: how to remove column header

2016-10-15 Thread Anthony
You can do a loop in the view -- just prepare a data structure in the 
controller and pass it to the view (i.e., move the queries to the 
controller). Actually, you can probably just do a single query including 
all items in taxonomy_set (and orderby that field) -- then just send the 
entire Rows object to the view and loop through it. Note, you should also 
probably avoid using the .render() method to translate each foreign key to 
its represented value, as that will issue a separate database query for 
each item. Instead, maybe change your query to do a join and include the 
relevant fields from the foreign table.

Anthonyh

On Saturday, October 15, 2016 at 5:34:02 PM UTC-4, Alex Glaros wrote:
>
> thanks Massimo and Anthony
>
> it's working now but don't know how to get around writing a loop in the 
> view.  Can you please explain in general principles how to get loop written 
> in controller to display in view?
>

-- 
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] Re: how to remove column header

2016-10-15 Thread Alex Glaros
thanks Massimo and Anthony

it's working now but don't know how to get around writing a loop in the 
view.  Can you please explain in general principles how to get loop written 
in controller to display in view?

-- 
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] Re: how to remove column header

2016-10-15 Thread Anthony
On Friday, October 14, 2016 at 9:35:51 PM UTC-4, Alex Glaros wrote:
>
> how to supress field header
>
>{{taxonomy_set = ['super_city_3', 'super_city_2', 'super_city_1', 
> 'city', 'sub_city_1', 'sub_city_2', 'sub_city_3']}}
> {{for r in taxonomy_set:}}
> {{db.geo_political_generic_fields_lookup.taxonomy_column_fk.label 
> = ''}} #does not work
>

The "label" attribute is used in forms -- not relevant here.
 

> {{geoFieldName = 
> db((db.geo_political_generic_fields_lookup.country_fk == specificCountryID) 
> & (db.geo_political_generic_fields_lookup.generic_geo_political_field_name 
> == r)).select(db.geo_political_generic_fields_lookup.taxonomy_column_fk)}}
> {{=r }}   translates to: {{=geoFieldName}}
> {{pass}}
>

The problem is that geoFieldName is the result of a .select(), so it is a 
Rows object -- when you insert a Rows object in a template, you get a 
SQLTABLE (with headings). Instead, you need 
.select(...).render(0).taxonomy_column_fk. The .render(0) extracts the 
record from the Rows object and applies the "represent" attributes of each 
of its fields (in this case, just the taxonomy_column_fk field). If you 
instead did .select(...).first().taxonomy_column_fk, you would get the 
actual foreign key value (i.e., an integer record ID) rather than the 
transformed representation of that foreign key.

Also, I would recommend moving most of that code out of the view -- views 
are for *displaying* data, not creating/generating it. Code in views is 
harder to read and debug.

Anthony

>

-- 
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] Re: how to remove column header

2016-10-15 Thread Massimo Di Pierro
I do not full understand. You select only the column db.geo_political_
generic_fields_lookup.taxonomy_column_fk
what d you want you want to remove it? You want to remove the header only?

You could replace {{=geoFieldName}}
with 
{{for row in geoFieldName:}}{{=row.taxonomy_column_fk
}}{{pass}}

On Friday, 14 October 2016 20:35:51 UTC-5, Alex Glaros wrote:
>
> how to supress field header
>
>{{taxonomy_set = ['super_city_3', 'super_city_2', 'super_city_1', 
> 'city', 'sub_city_1', 'sub_city_2', 'sub_city_3']}}
> {{for r in taxonomy_set:}}
> {{db.geo_political_generic_fields_lookup.taxonomy_column_fk.label 
> = ''}} #does not work
> {{geoFieldName = 
> db((db.geo_political_generic_fields_lookup.country_fk == specificCountryID) 
> & (db.geo_political_generic_fields_lookup.generic_geo_political_field_name 
> == r)).select(db.geo_political_generic_fields_lookup.taxonomy_column_fk)}}
> {{=r }}   translates to: {{=geoFieldName}}
> {{pass}}
>
> PRODUCES
>
> *super_city_3* translates to:
> geo_political_generic_fields_lookup.taxonomy_column_fk  # want to remove 
> this header
> Federal US government 
> *super_city_2* translates to:
> geo_political_generic_fields_lookup.taxonomy_column_fk # want to remove 
> this header 
> State
> *super_city_1* translates to:
> geo_political_generic_fields_lookup.taxonomy_column_fk # want to remove 
> this header
> County
>
> thanks,
>
> Alex Glaros
>

-- 
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.