[web2py] Re: Is it possible reload my model.py from an ajax request?
Yeah, you were right, now it works! :) My final code is like this: the model remains the same. controller: def redTrafico(): red_trafico = SQLFORM.grid(db.red_trafico) return locals() def canal(): canal = SQLFORM.grid(db.canal) return locals() def onChangeRedTrafico(): options = [] for opcion in db(db.canal.id_red_trafico == request.vars.red_trafico).select(db.canal.ALL): options.append(OPTION(opcion.nombre, _value=opcion.id)) return SELECT(options) @auth.requires_login() def index(): formulario = SQLFORM.grid(db.formulario) formulario_red_trafico = formulario.element('select[id=formulario_red_trafico]') if formulario_red_trafico is not None: formulario_red_trafico['_onchange'] = 'onChangeRedTrafico()' return dict(formulario=formulario) And finally my view: {{left_sidebar_enabled,right_sidebar_enabled=False,('message' in globals())}} {{extend 'layout.html'}} console.log('seccion javascript ejecutada') function onChangeRedTrafico(){ eval("ajax('{{=URL('default', 'onChangeRedTrafico')}}', ['red_trafico'], 'formulario_canal')"); } Red Trafico Canal {{=formulario}} Thank you Anthony for your explanation! ("...if you need the HTML on the page to change as the result of an Ajax request, then the Ajax request must actually return the new HTML (or return the relevant data needed for the JS code to construct the HTML).") El viernes, 5 de agosto de 2016, 16:18:04 (UTC-5), Anthony escribió: > > Yeah, that's not going to work. All your Ajax callback does is set the > validator for the field in question, but it doesn't do or return anything. > That change is only in effect for the duration of the Ajax request itself. > It will not change any HTML on the page (as you do not return an HTML), nor > will it affect any subsequent requests (e.g., the form submission). > > Note, your application code is executed on every request, so changing an > attribute in one request does not persist to subsequent requests. If you > need the validator to have a particular value upon form submission, you > will need to set that value within the same request as the submission > itself. Also, if you need the HTML on the page to change as the result of > an Ajax request, then the Ajax request must actually return the new HTML > (or return the relevant data needed for the JS code to construct the HTML). > > Anthony > > On Friday, August 5, 2016 at 4:19:22 PM UTC-4, Bernardo Leon wrote: >> >> The thing is I have already tried that but I got no luck, I know my >> controller method is executed but the child selector still uses the >> validator defined in the model file. If I don't declare the validator in >> the model file expecting that my controller code assign a new validator it >> also does nothing. >> >> This is my model file: >> >> # -*- coding: utf-8 -*- >> from gluon.tools import Auth >> >> db = DAL('sqlite://modelo.db') >> auth=Auth(db) >> auth.define_tables(username=False, signature=True) >> >> db.define_table('red_trafico', >>Field('nombre', 'string')) >> >> db.define_table('canal', >>Field('id_red_trafico', 'reference red_trafico'), >>Field('nombre', 'string')) >> >> db.define_table('formulario', >>Field('red_trafico', 'reference red_trafico'), >>Field('canal', 'reference canal')) >> >> db.canal.id_red_trafico.requires = IS_IN_DB(db, 'red_trafico.id', >> '%(nombre)s') >> db.formulario.red_trafico.requires = IS_IN_DB(db, 'red_trafico.id', >> '%(nombre)s') >> db.formulario.canal.requires = IS_IN_DB(db, 'canal.id', '%(nombre)s') >> >> >> >> this is my controller: >> >> formulario = SQLFORM.grid(db.formulario) >> >> def redTrafico(): >> red_trafico = SQLFORM.grid(db.red_trafico) >> return locals() >> >> def canal(): >> canal = SQLFORM.grid(db.canal) >> return locals() >> >> def onChangeRedTrafico(): >> db.formulario.canal.requires = IS_IN_DB(db(db.canal.id_red_trafico == >> request.vars.red_trafico), 'canal.id', '%(nombre)s') >> print 'requires modificado' >> >> def index(): >> """ >> example action using the internationalization operator T and flash >> rendered by views/default/index.html or views/generic.html >> >> if you need a simple wiki simply replace the two lines below with: >> return auth.wiki() >> """ >> formulario_red_trafico = >> formulario.element('select[id=formulario_red_trafico]') >> formulario_red_trafico['_onchange'] = 'onChangeRedTrafico()' >> return dict(formulario=formulario) >> >> >> And this is my view: >> >> {{left_sidebar_enabled,right_sidebar_enabled=False,('message' in >> globals())}} >> {{extend 'layout.html'}} >> >> >> console.log('seccion javascript ejecutada') >> function onChangeRedTrafico(){ >> eval("ajax('{{=URL('default', 'onChangeRedTrafico')}}', >> ['red_trafico'], '')"); >> } >> >> >> Red Trafico >> >> Canal >
[web2py] Re: Is it possible reload my model.py from an ajax request?
Yeah, that's not going to work. All your Ajax callback does is set the validator for the field in question, but it doesn't do or return anything. That change is only in effect for the duration of the Ajax request itself. It will not change any HTML on the page (as you do not return an HTML), nor will it affect any subsequent requests (e.g., the form submission). Note, your application code is executed on every request, so changing an attribute in one request does not persist to subsequent requests. If you need the validator to have a particular value upon form submission, you will need to set that value within the same request as the submission itself. Also, if you need the HTML on the page to change as the result of an Ajax request, then the Ajax request must actually return the new HTML (or return the relevant data needed for the JS code to construct the HTML). Anthony On Friday, August 5, 2016 at 4:19:22 PM UTC-4, Bernardo Leon wrote: > > The thing is I have already tried that but I got no luck, I know my > controller method is executed but the child selector still uses the > validator defined in the model file. If I don't declare the validator in > the model file expecting that my controller code assign a new validator it > also does nothing. > > This is my model file: > > # -*- coding: utf-8 -*- > from gluon.tools import Auth > > db = DAL('sqlite://modelo.db') > auth=Auth(db) > auth.define_tables(username=False, signature=True) > > db.define_table('red_trafico', >Field('nombre', 'string')) > > db.define_table('canal', >Field('id_red_trafico', 'reference red_trafico'), >Field('nombre', 'string')) > > db.define_table('formulario', >Field('red_trafico', 'reference red_trafico'), >Field('canal', 'reference canal')) > > db.canal.id_red_trafico.requires = IS_IN_DB(db, 'red_trafico.id', > '%(nombre)s') > db.formulario.red_trafico.requires = IS_IN_DB(db, 'red_trafico.id', > '%(nombre)s') > db.formulario.canal.requires = IS_IN_DB(db, 'canal.id', '%(nombre)s') > > > > this is my controller: > > formulario = SQLFORM.grid(db.formulario) > > def redTrafico(): > red_trafico = SQLFORM.grid(db.red_trafico) > return locals() > > def canal(): > canal = SQLFORM.grid(db.canal) > return locals() > > def onChangeRedTrafico(): > db.formulario.canal.requires = IS_IN_DB(db(db.canal.id_red_trafico == > request.vars.red_trafico), 'canal.id', '%(nombre)s') > print 'requires modificado' > > def index(): > """ > example action using the internationalization operator T and flash > rendered by views/default/index.html or views/generic.html > > if you need a simple wiki simply replace the two lines below with: > return auth.wiki() > """ > formulario_red_trafico = > formulario.element('select[id=formulario_red_trafico]') > formulario_red_trafico['_onchange'] = 'onChangeRedTrafico()' > return dict(formulario=formulario) > > > And this is my view: > > {{left_sidebar_enabled,right_sidebar_enabled=False,('message' in > globals())}} > {{extend 'layout.html'}} > > > console.log('seccion javascript ejecutada') > function onChangeRedTrafico(){ > eval("ajax('{{=URL('default', 'onChangeRedTrafico')}}', > ['red_trafico'], '')"); > } > > > Red Trafico > > Canal > > {{=formulario}} > > I am using web2py version: Version > 2.14.6-stable+timestamp.2016.05.10.00.21.47 > > Is something wrong with my code? Because my onChangeRedTrafico() controller > method (where I change the validator) gets called but nothing happens > > Thanks > > > El viernes, 5 de agosto de 2016, 13:58:02 (UTC-5), Anthony escribió: >> >> On Friday, August 5, 2016 at 12:28:44 PM UTC-4, Bernardo Leon wrote: >>> >>> Hi, I have an SQLFORM.grid form and when I am inserting data I want to >>> make the selectors work in cascade. I have seen some recipies where they >>> create by hand the form using plain html and throw some jQuery in the >>> middle but I dont like it, I like the cleaness of web2py so I am looking >>> for a cleaner way to accomplish this. >>> >>> So far I am trying with ajax request and I have been able to call a >>> function in my controller passing the id of the parent selector to finally >>> change the child's selector IS_IN_DB validator. That was my idea, but it >>> seems I cannot change the validator from de controller, only from the >>> model; so is there a way to reload the model within an ajax request so I >>> can change the behavior of my form at runtime? Is there a better/cleaner >>> way to accomplish this? >>> >> >> First, note that the model file is re-executed on every request, so >> indeed it does "reload" when you make an Ajax request. The problem is, your >> model includes no logic to change the validator when the Ajax request is >> made. You could add such logic, perhaps by sending some flag with the Ajax >> request, or simply setting the alternative valid
[web2py] Re: Is it possible reload my model.py from an ajax request?
The thing is I have already tried that but I got no luck, I know my controller method is executed but the child selector still uses the validator defined in the model file. If I don't declare the validator in the model file expecting that my controller code assign a new validator it also does nothing. This is my model file: # -*- coding: utf-8 -*- from gluon.tools import Auth db = DAL('sqlite://modelo.db') auth=Auth(db) auth.define_tables(username=False, signature=True) db.define_table('red_trafico', Field('nombre', 'string')) db.define_table('canal', Field('id_red_trafico', 'reference red_trafico'), Field('nombre', 'string')) db.define_table('formulario', Field('red_trafico', 'reference red_trafico'), Field('canal', 'reference canal')) db.canal.id_red_trafico.requires = IS_IN_DB(db, 'red_trafico.id', '%(nombre)s') db.formulario.red_trafico.requires = IS_IN_DB(db, 'red_trafico.id', '%(nombre)s') db.formulario.canal.requires = IS_IN_DB(db, 'canal.id', '%(nombre)s') this is my controller: formulario = SQLFORM.grid(db.formulario) def redTrafico(): red_trafico = SQLFORM.grid(db.red_trafico) return locals() def canal(): canal = SQLFORM.grid(db.canal) return locals() def onChangeRedTrafico(): db.formulario.canal.requires = IS_IN_DB(db(db.canal.id_red_trafico == request.vars.red_trafico), 'canal.id', '%(nombre)s') print 'requires modificado' def index(): """ example action using the internationalization operator T and flash rendered by views/default/index.html or views/generic.html if you need a simple wiki simply replace the two lines below with: return auth.wiki() """ formulario_red_trafico = formulario.element('select[id=formulario_red_trafico]') formulario_red_trafico['_onchange'] = 'onChangeRedTrafico()' return dict(formulario=formulario) And this is my view: {{left_sidebar_enabled,right_sidebar_enabled=False,('message' in globals())}} {{extend 'layout.html'}} console.log('seccion javascript ejecutada') function onChangeRedTrafico(){ eval("ajax('{{=URL('default', 'onChangeRedTrafico')}}', ['red_trafico'], '')"); } Red Trafico Canal {{=formulario}} I am using web2py version: Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 Is something wrong with my code? Because my onChangeRedTrafico() controller method (where I change the validator) gets called but nothing happens Thanks El viernes, 5 de agosto de 2016, 13:58:02 (UTC-5), Anthony escribió: > > On Friday, August 5, 2016 at 12:28:44 PM UTC-4, Bernardo Leon wrote: >> >> Hi, I have an SQLFORM.grid form and when I am inserting data I want to >> make the selectors work in cascade. I have seen some recipies where they >> create by hand the form using plain html and throw some jQuery in the >> middle but I dont like it, I like the cleaness of web2py so I am looking >> for a cleaner way to accomplish this. >> >> So far I am trying with ajax request and I have been able to call a >> function in my controller passing the id of the parent selector to finally >> change the child's selector IS_IN_DB validator. That was my idea, but it >> seems I cannot change the validator from de controller, only from the >> model; so is there a way to reload the model within an ajax request so I >> can change the behavior of my form at runtime? Is there a better/cleaner >> way to accomplish this? >> > > First, note that the model file is re-executed on every request, so indeed > it does "reload" when you make an Ajax request. The problem is, your model > includes no logic to change the validator when the Ajax request is made. > You could add such logic, perhaps by sending some flag with the Ajax > request, or simply setting the alternative validator whenever request.ajax > == True. > > However, there is no need to make the change in the model file where the > table is initially defined, as you can change the validators for a given > field at any point in your code, such as in the controller. So, in the > controller that handles the Ajax request, you could do: > > db.mytable.myfield.requires = new_validator > > 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 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.
Re: [web2py] Re: Is it possible reload my model.py from an ajax request?
On Friday, August 5, 2016 at 3:25:22 PM UTC-4, Richard wrote: > > Yes, basic example... You need to input data into a denormalized table, so > depend on the type of input you want to make product a vs b, some fields > are going to be ignore or required... In this case there is many way of > doing it... But I would like to be possible to define my validator once so > it behave properly in any situation. web2py use individual field validator > workflow, but in case of denormalized table or custom form for which you > process input afterward you may need field validation that would depend on > other fields input. We should have some basic way of supporting common > pattern in such kind of situation to rely less on jQuery of custom > validator. > Yes, we have the onvalidation callback, as well as the possibility for individual field validators to reference request.vars to inspect the values of other fields. 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 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.
Re: [web2py] Re: Is it possible reload my model.py from an ajax request?
Yes, basic example... You need to input data into a denormalized table, so depend on the type of input you want to make product a vs b, some fields are going to be ignore or required... In this case there is many way of doing it... But I would like to be possible to define my validator once so it behave properly in any situation. web2py use individual field validator workflow, but in case of denormalized table or custom form for which you process input afterward you may need field validation that would depend on other fields input. We should have some basic way of supporting common pattern in such kind of situation to rely less on jQuery of custom validator. Richard On Fri, Aug 5, 2016 at 3:03 PM, Anthony wrote: > On Friday, August 5, 2016 at 2:39:09 PM UTC-4, Richard wrote: >> >> So, what you ask, modifying validator and return a new select element >> with new validations properties is not possible for now in web2py to my >> knowledge... >> > > If you are making a separate Ajax request after the initial form has been > loaded, you can change the validator associated with a particular field and > return a new select element. > > >> The consequences of this is that it is not possible to create a truelly >> dynamic form with web2py as the form is created and processed server side... >> > > I suppose what you mean by a "truly dynamic" form is one that requires > Javascript and possible additional server communication (via Ajax or > websockets). If so, that is possible in web2py, though web2py doesn't > provide any built-in convenience methods to facilitate this. > > 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 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. > -- 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.
Re: [web2py] Re: Is it possible reload my model.py from an ajax request?
On Friday, August 5, 2016 at 2:39:09 PM UTC-4, Richard wrote: > > So, what you ask, modifying validator and return a new select element with > new validations properties is not possible for now in web2py to my > knowledge... > If you are making a separate Ajax request after the initial form has been loaded, you can change the validator associated with a particular field and return a new select element. > The consequences of this is that it is not possible to create a truelly > dynamic form with web2py as the form is created and processed server side... > I suppose what you mean by a "truly dynamic" form is one that requires Javascript and possible additional server communication (via Ajax or websockets). If so, that is possible in web2py, though web2py doesn't provide any built-in convenience methods to facilitate this. 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 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.
[web2py] Re: Is it possible reload my model.py from an ajax request?
On Friday, August 5, 2016 at 12:28:44 PM UTC-4, Bernardo Leon wrote: > > Hi, I have an SQLFORM.grid form and when I am inserting data I want to > make the selectors work in cascade. I have seen some recipies where they > create by hand the form using plain html and throw some jQuery in the > middle but I dont like it, I like the cleaness of web2py so I am looking > for a cleaner way to accomplish this. > > So far I am trying with ajax request and I have been able to call a > function in my controller passing the id of the parent selector to finally > change the child's selector IS_IN_DB validator. That was my idea, but it > seems I cannot change the validator from de controller, only from the > model; so is there a way to reload the model within an ajax request so I > can change the behavior of my form at runtime? Is there a better/cleaner > way to accomplish this? > First, note that the model file is re-executed on every request, so indeed it does "reload" when you make an Ajax request. The problem is, your model includes no logic to change the validator when the Ajax request is made. You could add such logic, perhaps by sending some flag with the Ajax request, or simply setting the alternative validator whenever request.ajax == True. However, there is no need to make the change in the model file where the table is initially defined, as you can change the validators for a given field at any point in your code, such as in the controller. So, in the controller that handles the Ajax request, you could do: db.mytable.myfield.requires = new_validator 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 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.
Re: [web2py] Re: Is it possible reload my model.py from an ajax request?
I mean you can't enforce On Fri, Aug 5, 2016 at 2:38 PM, Richard Vézina wrote: > That exactly one of my point about future of web2py and Massimo's > experimentation like w3 and more recently DBAPI ( > https://groups.google.com/d/msg/web2py-developers/jd7W_XS92aw/pZYzX07jAQAJ > ) > > Here : > https://groups.google.com/forum/#!msg/web2py-developers/x23GReU0McM/5kX42ft-PAAJ > > So, what you ask, modifying validator and return a new select element with > new validations properties is not possible for now in web2py to my > knowledge... The only way I can se you could make it works right would be > to create a custom validator in the which you will write the logic you need > in order for it behavior to change following and ajax call depending of > some available value in the select for instance... A lot of work. > > The consequences of this is that it is not possible to create a truelly > dynamic form with web2py as the form is created and processed server > side... That because you can't modified the property of the field validator > base on value of other fields for instance... It can be done as I explain > by create custom validator somehow with a lot of work and for custome > purpose... But let say you have to make some field (and validator) > accepting empty value when a certain value is selected in another field it > is actually difficult to do and you have to leave the field at > IS_EMPTY_OR(IS_IN_DB(...)) which is not interresting as some fields may end > empty because you enforce mandatory field base on data input in other > fields. So you need to rely on heavy jQuery script to achieve dynimic > form... > > Richard > > > > > > > On Fri, Aug 5, 2016 at 2:05 PM, Bernardo Leon > wrote: > >> It seems to be an interesting library but it is kind of expensive from >> what I see and I think it does not integrate with web2py, at least not with >> SQLFORM.crud. Thanks for the suggestion anyway! >> >> >> El viernes, 5 de agosto de 2016, 12:57:40 (UTC-5), Ron Chatterjee >> escribió: >>> >>> http://demos.telerik.com/kendo-ui/dropdownlist/cascadingdropdownlist >>> >>> might help >>> >>> On Friday, August 5, 2016 at 1:28:01 PM UTC-4, Bernardo Leon wrote: No, I am trying to get the cascade dropdowns working. I want to make an AJAX call from the parent dropdown AND refresh the child El viernes, 5 de agosto de 2016, 12:23:04 (UTC-5), Antonio Salazar escribió: > > Are you saying you managed to cascade the dropdowns, or just make an > AJAX call from the parent dropdown without refreshing the child? > > On Friday, August 5, 2016 at 11:28:44 AM UTC-5, Bernardo Leon wrote: >> >> Hi, I have an SQLFORM.grid form and when I am inserting data I want >> to make the selectors work in cascade. I have seen some recipies where >> they >> create by hand the form using plain html and throw some jQuery in the >> middle but I dont like it, I like the cleaness of web2py so I am looking >> for a cleaner way to accomplish this. >> >> So far I am trying with ajax request and I have been able to call a >> function in my controller passing the id of the parent selector to >> finally >> change the child's selector IS_IN_DB validator. That was my idea, but it >> seems I cannot change the validator from de controller, only from the >> model; so is there a way to reload the model within an ajax request so I >> can change the behavior of my form at runtime? Is there a better/cleaner >> way to accomplish this? >> >> Thank you! >> > -- >> 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. >> > > -- 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.
Re: [web2py] Re: Is it possible reload my model.py from an ajax request?
That exactly one of my point about future of web2py and Massimo's experimentation like w3 and more recently DBAPI ( https://groups.google.com/d/msg/web2py-developers/jd7W_XS92aw/pZYzX07jAQAJ) Here : https://groups.google.com/forum/#!msg/web2py-developers/x23GReU0McM/5kX42ft-PAAJ So, what you ask, modifying validator and return a new select element with new validations properties is not possible for now in web2py to my knowledge... The only way I can se you could make it works right would be to create a custom validator in the which you will write the logic you need in order for it behavior to change following and ajax call depending of some available value in the select for instance... A lot of work. The consequences of this is that it is not possible to create a truelly dynamic form with web2py as the form is created and processed server side... That because you can't modified the property of the field validator base on value of other fields for instance... It can be done as I explain by create custom validator somehow with a lot of work and for custome purpose... But let say you have to make some field (and validator) accepting empty value when a certain value is selected in another field it is actually difficult to do and you have to leave the field at IS_EMPTY_OR(IS_IN_DB(...)) which is not interresting as some fields may end empty because you enforce mandatory field base on data input in other fields. So you need to rely on heavy jQuery script to achieve dynimic form... Richard On Fri, Aug 5, 2016 at 2:05 PM, Bernardo Leon wrote: > It seems to be an interesting library but it is kind of expensive from > what I see and I think it does not integrate with web2py, at least not with > SQLFORM.crud. Thanks for the suggestion anyway! > > > El viernes, 5 de agosto de 2016, 12:57:40 (UTC-5), Ron Chatterjee escribió: >> >> http://demos.telerik.com/kendo-ui/dropdownlist/cascadingdropdownlist >> >> might help >> >> On Friday, August 5, 2016 at 1:28:01 PM UTC-4, Bernardo Leon wrote: >>> >>> No, I am trying to get the cascade dropdowns working. >>> >>> I want to make an AJAX call from the parent dropdown AND refresh the >>> child >>> >>> El viernes, 5 de agosto de 2016, 12:23:04 (UTC-5), Antonio Salazar >>> escribió: Are you saying you managed to cascade the dropdowns, or just make an AJAX call from the parent dropdown without refreshing the child? On Friday, August 5, 2016 at 11:28:44 AM UTC-5, Bernardo Leon wrote: > > Hi, I have an SQLFORM.grid form and when I am inserting data I want to > make the selectors work in cascade. I have seen some recipies where they > create by hand the form using plain html and throw some jQuery in the > middle but I dont like it, I like the cleaness of web2py so I am looking > for a cleaner way to accomplish this. > > So far I am trying with ajax request and I have been able to call a > function in my controller passing the id of the parent selector to finally > change the child's selector IS_IN_DB validator. That was my idea, but it > seems I cannot change the validator from de controller, only from the > model; so is there a way to reload the model within an ajax request so I > can change the behavior of my form at runtime? Is there a better/cleaner > way to accomplish this? > > Thank you! > -- > 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. > -- 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.
[web2py] Re: Is it possible reload my model.py from an ajax request?
It seems to be an interesting library but it is kind of expensive from what I see and I think it does not integrate with web2py, at least not with SQLFORM.crud. Thanks for the suggestion anyway! El viernes, 5 de agosto de 2016, 12:57:40 (UTC-5), Ron Chatterjee escribió: > > http://demos.telerik.com/kendo-ui/dropdownlist/cascadingdropdownlist > > might help > > On Friday, August 5, 2016 at 1:28:01 PM UTC-4, Bernardo Leon wrote: >> >> No, I am trying to get the cascade dropdowns working. >> >> I want to make an AJAX call from the parent dropdown AND refresh the child >> >> El viernes, 5 de agosto de 2016, 12:23:04 (UTC-5), Antonio Salazar >> escribió: >>> >>> Are you saying you managed to cascade the dropdowns, or just make an >>> AJAX call from the parent dropdown without refreshing the child? >>> >>> On Friday, August 5, 2016 at 11:28:44 AM UTC-5, Bernardo Leon wrote: Hi, I have an SQLFORM.grid form and when I am inserting data I want to make the selectors work in cascade. I have seen some recipies where they create by hand the form using plain html and throw some jQuery in the middle but I dont like it, I like the cleaness of web2py so I am looking for a cleaner way to accomplish this. So far I am trying with ajax request and I have been able to call a function in my controller passing the id of the parent selector to finally change the child's selector IS_IN_DB validator. That was my idea, but it seems I cannot change the validator from de controller, only from the model; so is there a way to reload the model within an ajax request so I can change the behavior of my form at runtime? Is there a better/cleaner way to accomplish this? Thank you! >>> -- 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.
[web2py] Re: Is it possible reload my model.py from an ajax request?
http://demos.telerik.com/kendo-ui/dropdownlist/cascadingdropdownlist might help On Friday, August 5, 2016 at 1:28:01 PM UTC-4, Bernardo Leon wrote: > > No, I am trying to get the cascade dropdowns working. > > I want to make an AJAX call from the parent dropdown AND refresh the child > > El viernes, 5 de agosto de 2016, 12:23:04 (UTC-5), Antonio Salazar > escribió: >> >> Are you saying you managed to cascade the dropdowns, or just make an AJAX >> call from the parent dropdown without refreshing the child? >> >> On Friday, August 5, 2016 at 11:28:44 AM UTC-5, Bernardo Leon wrote: >>> >>> Hi, I have an SQLFORM.grid form and when I am inserting data I want to >>> make the selectors work in cascade. I have seen some recipies where they >>> create by hand the form using plain html and throw some jQuery in the >>> middle but I dont like it, I like the cleaness of web2py so I am looking >>> for a cleaner way to accomplish this. >>> >>> So far I am trying with ajax request and I have been able to call a >>> function in my controller passing the id of the parent selector to finally >>> change the child's selector IS_IN_DB validator. That was my idea, but it >>> seems I cannot change the validator from de controller, only from the >>> model; so is there a way to reload the model within an ajax request so I >>> can change the behavior of my form at runtime? Is there a better/cleaner >>> way to accomplish this? >>> >>> Thank you! >>> >> -- 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.
[web2py] Re: Is it possible reload my model.py from an ajax request?
No, I am trying to get the cascade dropdowns working. I want to make an AJAX call from the parent dropdown AND refresh the child El viernes, 5 de agosto de 2016, 12:23:04 (UTC-5), Antonio Salazar escribió: > > Are you saying you managed to cascade the dropdowns, or just make an AJAX > call from the parent dropdown without refreshing the child? > > On Friday, August 5, 2016 at 11:28:44 AM UTC-5, Bernardo Leon wrote: >> >> Hi, I have an SQLFORM.grid form and when I am inserting data I want to >> make the selectors work in cascade. I have seen some recipies where they >> create by hand the form using plain html and throw some jQuery in the >> middle but I dont like it, I like the cleaness of web2py so I am looking >> for a cleaner way to accomplish this. >> >> So far I am trying with ajax request and I have been able to call a >> function in my controller passing the id of the parent selector to finally >> change the child's selector IS_IN_DB validator. That was my idea, but it >> seems I cannot change the validator from de controller, only from the >> model; so is there a way to reload the model within an ajax request so I >> can change the behavior of my form at runtime? Is there a better/cleaner >> way to accomplish this? >> >> Thank you! >> > -- 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.
[web2py] Re: Is it possible reload my model.py from an ajax request?
Are you saying you managed to cascade the dropdowns, or just make an AJAX call from the parent dropdown without refreshing the child? On Friday, August 5, 2016 at 11:28:44 AM UTC-5, Bernardo Leon wrote: > > Hi, I have an SQLFORM.grid form and when I am inserting data I want to > make the selectors work in cascade. I have seen some recipies where they > create by hand the form using plain html and throw some jQuery in the > middle but I dont like it, I like the cleaness of web2py so I am looking > for a cleaner way to accomplish this. > > So far I am trying with ajax request and I have been able to call a > function in my controller passing the id of the parent selector to finally > change the child's selector IS_IN_DB validator. That was my idea, but it > seems I cannot change the validator from de controller, only from the > model; so is there a way to reload the model within an ajax request so I > can change the behavior of my form at runtime? Is there a better/cleaner > way to accomplish this? > > Thank you! > -- 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.