Smartgrid and onvalidation for child tables

81 views
Skip to first unread message

Seraaj Muneer

unread,
Feb 17, 2016, 11:48:49 AM2/17/16
to web2py-users
Hello everyone, according to the Book, the smartgrid can be passed a map of parameters, eg searchable=dict(parent=True, child=False), and this will be passed to the appropriate grids that the smartgrid creates. 

Now I am wondering how to pass an onvalidation call back to both a parent and a child. Here's my code

def documents():
response.title = 'Employee Documents '

get_default_company_id() or redirect(URL('company', 'companies'))
grid = SQLFORM.smartgrid(db.employee, deletable=False, linked_tables=['employee_document'], csv=False,
orderby=dict(employee=db.employee.last_name,
employee_document=db.employee_document.document_type),
onvalidation=dict(employee=on_validate, employee_document=on_validate_doc),
showbuttontext=dict(employee=False, employee_document=False)
)
return dict(grid=grid)

but this results in an error

<type 'exceptions.RuntimeError'> Invalid key in onvalidate dict


If I remove the onvalidation part from the above code, it runs fine.

So my question again is, how do I pass a function to be called for onvalidation for a child grid created from a smartgrid? Thanks

Anthony

unread,
Feb 17, 2016, 3:15:20 PM2/17/16
to web2py-users
Hmm, doesn't appear to support all of the grid arguments:

for key in 'columns,orderby,searchable,sortable,paginate,deletable,editable,details,selectable,create,fields'.split(','):

Maybe make a feature request on Github to include all of the grid arguments, not just those above.

Anthony

Saeed

unread,
Feb 17, 2016, 3:26:00 PM2/17/16
to web...@googlegroups.com

Ah OK great. I'll have to raise a github request then.

--
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/WG28up_5YCs/unsubscribe.
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/d/optout.

Seraaj Muneer

unread,
Feb 18, 2016, 8:42:16 AM2/18/16
to web2py-users
Reply all
Reply to author
Forward
0 new messages