One way to do it is parse the args. ar = request.args # save typing
if len(ar) > 2 and ar[-1] == 'mytable' and ar[-2]=='new': # Yes, there is a more concise way to do this with slices oncreate= myfunctiononcreate else: oncreate=None if len(ar) > 3 and isinstance(ar[-1], int) and ar[-2]=='mytable' and ar[-1]=='edit': onupdate=myfunctiononupdate else myfunctiononupdate=None form = SQLFORM.grid( ..., oncreate=oncreate, onupdate=onupdate ....) On Friday, March 15, 2013 11:42:20 AM UTC-4, software.ted wrote: > > So what is the conclusion? how can you fire a callback for a function when > a child table has a field added or edited using oncreate and onupdate > respectively. > > On Wednesday, 7 November 2012 14:43:26 UTC+2, vivek wrote: >> >> Hmmm , >> >> unsure of how to determine the different table , i tried using >> forms.vars.net - as this field is unique to my parent table in the same >> oncreate function. So basically , I have forms.vars.xyz from my child table >> and able to use it to do what i need. But forms.vars.net is unusable >> which means oncreate ,onupdate doesnt trigger for parent table. >> >> Any work arounds for this? >> >> >> >> >> On Wednesday, November 7, 2012 5:21:50 AM UTC+4, howesc wrote: >>> >>> good question.....i don't know the answer to it, but i suspect there is >>> a way in your oncreate method to determine which table just had a creation >>> and do different actions based on that. >>> >>> On Monday, November 5, 2012 11:41:17 PM UTC-8, vivek wrote: >>>> >>>> >>>> Hi , >>>> >>>> So in this case how do I make sure it fires only when a new >>>> record is created for the child table in this case "quotelines" . Suppose >>>> if I have 2 different functions to be fired for the parent - oncreate and >>>> child - oncreate? >>>> >>>> Regards, >>>> Vivek >>>> >>>> >>>> >>>> On Monday, October 29, 2012 11:39:08 PM UTC+4, howesc wrote: >>>>> >>>>> something like: >>>>> >>>>> def myondelete(table, row_id): >>>>> .... >>>>> pass >>>>> >>>>> form = SQLFORM.smartgrid(..., ondelete=myondelete, ...) >>>>> >>>>> >>>>> >>>>> On Sunday, October 28, 2012 6:57:12 AM UTC-7, vivek wrote: >>>>>> >>>>>> So how would the new code be? I am a newbie a bit of direction needed! >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> On Sun, Oct 28, 2012 at 5:39 PM, Niphlod <nip...@gmail.com> wrote: >>>>>> >>>>>>> oncreate, ondelete, onupdate are callbacks to functions, not >>>>>>> dicts.... >>>>>>> >>>>>>> >>>>>>> On Sunday, October 28, 2012 12:26:39 PM UTC+1, vivek wrote: >>>>>>>> >>>>>>>> Hi, >>>>>>>> >>>>>>>> @auth.requires_login() >>>>>>>> def index(): >>>>>>>> response.view = 'Final/pricelist.html' >>>>>>>> form = SQLFORM.smartgrid(db.sourcelis**t,linked_tables=[ >>>>>>>> 'itemowner'],**deletable=dict(sourcelist=Fals**e,itemowner=True),editable >>>>>>>> =dict(sourcelist=False**,itemowner=True), details=dict(sourcelist= >>>>>>>> False,**itemowner=False),links = dict(project=[lambda row: A(SPAN( >>>>>>>> _class='icol-find'),_**href=URL("sourcelist","**itemowner",args=[ >>>>>>>> row.id]))]),o**ncreate=dict(itemowner=[avgpri**ce]),ondelete=dict( >>>>>>>> itemowner=[**'avgprice'])) >>>>>>>> return dict(form=form) >>>>>>>> >>>>>>>> @auth.requires_login() >>>>>>>> def avgprice(): >>>>>>>> ....... >>>>>>>> >>>>>>>> The above is my code . "itemowner" is my child table. I have >>>>>>>> manually tried running avgprice() from appadmin to make sure it works. >>>>>>>> There wasnt an issue. I just need to get the smartgrid to trigger >>>>>>>> avgprice. >>>>>>>> >>>>>>>> Thanks! >>>>>>>> >>>>>>>> -- >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> -- --- 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/groups/opt_out.