Thank you so much. This works like a charm. 2015-11-01 14:24 GMT+08:00 Anthony <abasta...@gmail.com>:
> I see the problem. When the grid involves a join, you must refer to fields > within a row via the row.table.field format. However, when you view/edit a > record from such a grid, only the record from a single table is shown > (i.e., there is no longer a join involved), so you must now refer to fields > within a row via the row.field format. Because your "link" appears in the > grid as well as in the view/edit page, whichever format you use to refer to > the id field, it will result in an error in one of those two contexts. > > So, all you need to do is ensure your code works in both contexts. Here's > a simple trick: > > Instead of: > > row.workers_skills.id > > do: > > row.get('workers_skills', row).id > > The .get() method retrieves the 'workers_skills' key, but if it doesn't > exist, it instead returns a default value, which in this case is just the > original row. We then retrieve the "id" field of that returned object > (either the original row or the row.workers_skills sub-row). > > This is a tricky problem to fix in a general way. The grid could > automatically set the "compact" attribute of the Rows object to False > whenever the grid involves a join, even when calling the view/edit actions, > which would enable a consistent interface for accessing field values. > However, that would then cause problems with widgets and represent > attributes defined on the database fields, which would be expecting > row.field syntax. > > In fact, there is a more general problem here -- any field represent > attribute that accesses other fields in the row will fail if the row is > part of a join. > > Anthony > > On Sunday, November 1, 2015 at 1:08:04 AM UTC-4, Yebach wrote: >> >> I dont have special function for edit. When I click the icon on to edit >> the record I get this error. I did not wrote any special function. I am >> using web2py's >> >> 2015-11-01 11:38 GMT+08:00 Anthony: >> >>> On Friday, October 30, 2015 at 11:03:18 PM UTC-4, Yebach wrote: >>>> >>>> The thing is IF I put links = [lambda row: A('',_class='glyphicon >>>> glyphicon glyphicon-remove-sign', >>>> callback=URL('settings','deactivate',vars=dict(table='workers_skills',field >>>> = 'ws_status' >>>> ,value = row.workers_skills.id )))] >>>> >>>> Then my function for "deleting" record works but when I want to go to >>>> edit I get an error. If I put row.id then the oposite >>>> >>> >>> I'm not sure I follow. What do you mean by "go to edit"? Assuming edit >>> is a separate action/page, how could the callback URL you are using for >>> delete affect the edit action? Can you show the code related to editing? >>> >>> 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 a topic in the >>> Google Groups "web2py-users" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/web2py/3T1Qaf39wJg/unsubscribe. >>> To unsubscribe from this group and all its topics, send an email to >>> web2py+unsubscr...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> Lep pozdrav >> >> Vid Ogris >> >> >> -- > 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 a topic in the > Google Groups "web2py-users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/web2py/3T1Qaf39wJg/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Lep pozdrav Vid Ogris -- 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.