Hi,
I have a smartgrid-table with a lot of persons. Now I want to select some
persons with a checkbox and print the names, etc of these persons.
I have tried:
def f1():
def select_for_print(row):
return INPUT(_name="pr%d" % row.id,
_type="checkbox",
_value="pr%d" % row.id,
value=False,
)
grid = SQLFORM.smartgrid(
db.auth_user,
linked_tables=['child'],
user_signature=False,
links=[dict(header='Print',body=select_for_print)],
)
form=FORM(
*grid, *
INPUT(_type='submit'))
if form.process().accepted:
response.flash='Accepted'
elif form.errors:
response.flash='Error'
else:
response.flash='Check'
return dict(form=form)
A nice grid appears with one additional column ...
Id<http://127.0.0.1:8000/smartgridtest/default/f1/auth_user?keywords=&order=auth_user.id>First
name<http://127.0.0.1:8000/smartgridtest/default/f1/auth_user?keywords=&order=auth_user.first_name>
Last
name<http://127.0.0.1:8000/smartgridtest/default/f1/auth_user?keywords=&order=auth_user.last_name>
E-mail<http://127.0.0.1:8000/smartgridtest/default/f1/auth_user?keywords=&order=auth_user.email>
Print
[email protected]
Children<http://127.0.0.1:8000/smartgridtest/default/f1/auth_user/child.parent/1>
View<http://127.0.0.1:8000/smartgridtest/default/f1/auth_user/view/auth_user/1>
Edit<http://127.0.0.1:8000/smartgridtest/default/f1/auth_user/edit/auth_user/1>
Delete <http://127.0.0.1:8000/smartgridtest/default/f1#null> 2MariaM
[email protected]<http://127.0.0.1:8000/smartgridtest/default/f1/auth_user/child.parent/2>
View<http://127.0.0.1:8000/smartgridtest/default/f1/auth_user/view/auth_user/2>
Edit<http://127.0.0.1:8000/smartgridtest/default/f1/auth_user/edit/auth_user/2>
Delete <http://127.0.0.1:8000/smartgridtest/default/f1#null> 3ErichM
[email protected]<http://127.0.0.1:8000/smartgridtest/default/f1/auth_user/child.parent/3>
View<http://127.0.0.1:8000/smartgridtest/default/f1/auth_user/view/auth_user/3>
Edit<http://127.0.0.1:8000/smartgridtest/default/f1/auth_user/edit/auth_user/3>
Delete <http://127.0.0.1:8000/smartgridtest/default/f1#null> Submit
... but it seems, that this form will never be accepted, because
response.flash always shows 'Check'
*(1) What shall I do to send the values of the checkboxes to the next
function?
(2) Is it possible to change the order so that the checkboxes will be the
first column of each row?*
Regards, Martin