On Monday, May 9, 2016 at 1:34:31 PM UTC-7, [email protected] wrote: > > Interesting! > > So, if I do: > > a = my_table.render() > > I get > > a is <bound method Rows.render of <Rows (10)>> > > How do I now access individual elements? like Rows[0], > Rows[1]..Rows[10].etc? because a[0] doesn't work. > > It appears that you have an iterator. Fromm the book:
f you don't specify an index, you get a generator to iterate over all the > rows: > for row in rows.render(): > print row.myfield <URL:http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=render#Rendering-rows-using-represent> /dps > > > On Monday, May 9, 2016 at 3:53:48 PM UTC-4, Anthony wrote: >> >> This has nothing to do with the IS_IN_SET validator, which simply does >> validation in your code (typically, it would also generate an HTML select >> widget in forms, but not in your code, as you have explicitly specified >> your own form widget). It also has nothing to do with the field's form >> widget, as that only controls the display in forms. >> >> Rather, it is related to how you represent list values in your view code. >> Keep in mind that "days" is a "list:string" field, so it stores lists. The >> resulting value of the field in each Row is a Python list. In a view, if >> you do something like: >> >> {{=some_python_list}} >> >> you will get a display like the one you are seeing. If you want an >> alternative display, it is your responsibility to produce it as you see >> fit, depending on the nature of your UI. >> >> In read-only forms and the grid, list:-type fields are displayed as >> comma-separated lists via their default "represent" attribute. However, if >> you are just inserting a list value in a view via {{=row.my_list_field}}, >> the "represent" attribute is not used. In that case, you need to use >> Rows.render() to generate each Row object, which will automatically apply >> the "represent" attributes of each field. >> >> Anthony >> >> On Monday, May 9, 2016 at 12:06:49 PM UTC-4, [email protected] wrote: >>> >>> day_str = ('Sun', 'Mon', 'Tues', 'wed') >>> >>> Field('days', type='list:string',,requires=IS_IN_SET ((day_str), >>> multiple=True),widget=lambda field, value: >>> SQLFORM.widgets.multiple.widget(field, value, size=3, style='divs', >>> label=True)), >>> >>> /view >>> {{=my_table.days}} >>> >>> One example >>> >>> >>> On Monday, May 9, 2016 at 11:35:20 AM UTC-4, Anthony wrote: >>>> >>>> Please show your code. >>>> >>>> On Sunday, May 8, 2016 at 7:15:22 PM UTC-4, [email protected] wrote: >>>>> >>>>> What would be the most efficient way to take out html tag for >>>>> IS_IN_SET (str) which outputs >>>>> >>>>> ['my string'] >>>>> >>>>> >>>>> Want to display. >>>>> >>>>> >>>>> my string >>>>> >>>>> >>>>> Is re.compile and re.sub are the only options? XML, sanitize =True >>>>> doesn't work. Thanks in advance. >>>>> >>>>> -- 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.

