SQLFLORMGRID

110 views
Skip to first unread message

lcham...@gmail.com

unread,
Oct 1, 2020, 10:07:34 AM10/1/20
to web2py-users

Hello,
i use sqlformgrid and like this :
controller:
def art_manage():
    records= SQLFORM.grid(query=db.t_art,maxtextlength = 40,deletable=False,create=True, fields=[db.t_art.f_name, db.t_art.f_team, db.t_art.f_tit])
    return dict(records=records)

view:
{{=records}}


the records displayed are good and i let the possibility to add records (create=True).
My question is : when i add a record and i submit i would to exectue a function , how can i do ?
Thank you

(i know how to do with form .. if form.process (onvalidation .. and so on)

agent tresdev

unread,
Oct 2, 2020, 11:04:06 AM10/2/20
to web2py-users
From the documentation:
"onvalidation, onfailure, oncreate, onupdate and ondelete are callback functions. All but ondelete take a form object as input, ondelete takes the table and the record id. Because the edit/create form is an SQLFORM which extends FORM, these callbacks are essentially used in the same way as documented in the sections for FORM and SQLFORM. "

So, when you declare the grid, you link the function that you want to run to: oncreate=myoncreate

AGRogers

unread,
Oct 4, 2020, 9:43:05 PM10/4/20
to web...@googlegroups.com
Hi

I have used the DAL to execute code before or after I make database changes. Maybe that might work in your situation:

Cheers
Andrew

___________________________
www.TenOutOfTen.org



--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/399f0935-40d6-4277-829e-2fe5f7f0784bn%40googlegroups.com.

lcham...@gmail.com

unread,
Oct 5, 2020, 5:18:56 AM10/5/20
to web2py-users
thank you, i test

lcham...@gmail.com

unread,
Oct 5, 2020, 5:19:08 AM10/5/20
to web2py-users
thank you

lcham...@gmail.com

unread,
Oct 8, 2020, 7:44:04 AM10/8/20
to web2py-users
i do not want to make change on databe , just launch a function like sending an email . Is it possible to to do:
in the function or in the model .. ? let me now better choice ?
db.mytable._before_insert.my_function_send_email()




Le lundi 5 octobre 2020 à 03:43:05 UTC+2, roge...@gmail.com a écrit :

Alex Beskopilny

unread,
Oct 8, 2020, 10:05:39 AM10/8/20
to web2py-users
maybe you could do this

def art_manage():

    if  len(request.args) >= 2 and ('new' == request.args[0]):
           # some code
           return ' create !!!!'

lcham...@gmail.com

unread,
Oct 8, 2020, 12:03:41 PM10/8/20
to web2py-users
good idea it works , thank you

i have to practise more
Reply all
Reply to author
Forward
0 new messages