Please provide the exact and all model, controller code related to the issue. Without that it hard to say.
Richard On Fri, Aug 12, 2016 at 3:06 AM, Vic Ding <dingqiq...@gmail.com> wrote: > Thanks for your reply, Richard. > in the database, there is an id field. I removed all the extra properties > of the grid and doing now simply > > grid = SQLFORM.grid(db.inoutexp) > > Even that is not working. Error is grid not defined. > > After a bit more investigation, I found the problem is related to use of > row in lambda function which could mean that grid is indeed not defined. > > In the db definition > > Field.Virtual('myamount', lambda row: float(row.price)*row.qty, > label=T('Amount')) > Field.Virtual('test', lambda row: 'hello') > > > The first one will break the code and second will work. > > > Any idea how to walk around the issue? Thanks again. > > > On Monday, August 8, 2016 at 3:42:26 PM UTC+2, Richard wrote: >> >> Do you have an "id" field defined? >> >> Richard >> >> On Sat, Aug 6, 2016 at 6:31 AM, Vic Ding <dingq...@gmail.com> wrote: >> >>> I created the table initially without the virtual field 'amount' and >>> added it lately. >>> When I use a string or number in the lambda like: lambda row: 'test', it >>> works fine. >>> However, when I use lambda row: row.id it gave the error below. It's >>> really like push here and feel the pain 2km away. >>> Someone get some idea? Thanks! >>> >>> my db: >>> >>> db.define_table('inoutexp', >>> auth.signature, >>> >>> >>> Field('qty', 'integer', requires=IS_NOT_EMPTY()), >>> Field.Virtual('amount', lambda row: row.qty, >>> label=T('Amount')) >>> >>> ) >>> >>> >>> simply a grid: >>> >>> grid = SQLFORM.grid(db.inoutexp) >>> >>> >>> The error: >>> >>> Function argument list >>> >>> (self=<Row { 'qty': 5, '...ime.datetime(2016, 8, 3, 14, 9, 46)}>, >>> k='inoutexp.amount') >>> Code listing >>> >>> 71. >>> 72. >>> 73. >>> 74. >>> 75. >>> 76. >>> >>> 77. >>> 78. >>> 79. >>> 80. >>> >>> self[key] = e(key) >>> return self[key] >>> except Exception as e: >>> raise e >>> >>> raise KeyError >>> >>> >>> __str__ = __repr__ = lambda self: '<Row %s>' % >>> self.as_dict(custom_types=[LazySet]) >>> >>> __int__ = lambda self: self.get('id') >>> >>> -- >>> 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+un...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > 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. > -- 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.