Re: [web2py] Create SQLFORM with one of its field's as ajax enabled
Hi Richard, Thanks for the answer. Actually i am able to achieve Ajax enabled text box in an SQLFORM...But the problem is the sqlform is auto generated by the SQLFORM.grid for that database. The code for SQLFORM which is working for normal tables is: DB.py db.define_table('tag',Field('name'),Field('campus'),Field('timezone')) def tag_data(): result = {} result['name'] = 'Neha' result['campus'] = 'Orion' result['timezone'] = 'America/newyork' db.tag.insert(**result) db.commit() db.define_table('timezone_list',Field('countries')) def timezone_list_data(): result = {} result['countries'] = 'Ireland' db.timezone_list.insert(**result) db.commit() def timezone_bulk(): db.timezone_list.bulk_insert([{'countries':'Africa/Abidjan'}, {'countries':'Africa/Accra'}, {'countries':'Africa/Addis_Ababa'}, {'countries':'Africa/Bamako'},{'countries':'America/Argentina/Buenos_Aires'}, {'countries':'America/Argentina/ComodRivadavia'}, {'countries':'America/Argentina/Rio_Gallegos'}, {'countries':'America/Cambridge_Bay'},{'countries':'America/Chicago'},{'countries':'America/Costa_Rica'},{'countries':'America/Detroit'}, {'countries':'Indian/Antananarivo'},{'countries':'Indian/Mahe'},{'countries':'Indian/Maldives'},{'countries':'Indian/Reunion'}, {'countries':'US/Hawaii'},{'countries':'US/Pacific'},{'countries':'UTC'},{'countries':'Zulu'}, {'countries':'Singapore'}]) db.commit() DEFAULT.py def month_input(): form=SQLFORM(db.tag) return locals() def month_selector(): if not request.vars.timezone: return '' pattern = request.vars.timezone.capitalize() + '%' selected = [row.countries for row in db(db.timezone_list.countries.like(pattern)).select()] return ''.join([DIV(k, _onclick="jQuery('#tag_timezone').val('%s'); jQuery('#suggestions').hide(); " % k, _onmouseover="this.style.backgroundColor='yellow'", _onmouseout="this.style.backgroundColor='white'", ).xml() for k in selected]) def timezone_list_dataF(): timezone_list_data() def timezone_bulkF(): timezone_bulk() month_input.html {{extend 'layout.html'}} {{=form}} #suggestions { position: relative; } .suggestions { background: white; border: solid 1px #55A6C8; } .suggestions DIV { padding: 2px 4px 2px 4px; } jQuery("#tag_timezone").keyup(function(){ jQuery('#suggestions').show(); ajax('month_selector', ['timezone'], 'suggestions')}); But i have to generate the same result for an auto generated SQLFORM.Actually we are using an sqlform.grid which has an inbuilt option for ADD.And on clicking on that an autogenerated SQLFORM for adding inputs opens.Now the goal is to add another field in that page which is ajax enabled.Can we do it?.Kindly helpThanks in advance.. On Thursday, 31 January 2013 20:32:13 UTC+5:30, Richard wrote: > Have you look at this plugin : > http://dev.s-cubism.com/plugin_lazy_options_widget > > It require a dependecy to suggest plugin as explained on the site, but you > can avoid using it. I already post answer to Jim on this list about that. > If you need more help with the integration of lazy option widget plugin let > me know... > > Richard > > > On Wed, Jan 30, 2013 at 11:59 PM, newbie >wrote: > >> Hi >> I m a newbie working on web2py,and i want to create an SQLForm >> with database Employee.The fields of db.Employee are name,campus,timzezone >> .I want the user to input in the SQLform ,but the last filed of timezone >> shud be such that when the user inputs in the field ,it shud present a >> dropdown of fields from another database called 'timezone_countries'.The >> user shud be able to select from the dropdown and submit the form .The code >> i have written in DB,Default,and view are here respectively:- >> DB.py >> >> db.define_table('Employee',Field('name'),Field('campus'),Field('timezone')) >> >> >> db.define_table('timezone_countries',Field('countries')) >> def timezone_countries_data(): >> result = {} >> result['countries'] = 'Brazil/Rio' >> db.timezone_countries.insert(**result) >> db.commit() >> >> DEFAULT.py >> def timezone_countries_dataF(): >> timezone_countries_data() >> >> def emp_input(): >> form=SQLFORM(db.Employee) >> return locals() >> >> def emp_selector(): >> if not request.vars.emp_timezone: >> --->where >> >> emp_timezone is the id of timezone in SQLFORM >> return ' ' >> pattern = request.vars.emp_timezone.capitalize() + '%' >> selected = [row.countries for row in >> db(db.timezone_countries.countries.like(pa
Re: [web2py] Create SQLFORM with one of its field's as ajax enabled
Have you look at this plugin : http://dev.s-cubism.com/plugin_lazy_options_widget It require a dependecy to suggest plugin as explained on the site, but you can avoid using it. I already post answer to Jim on this list about that. If you need more help with the integration of lazy option widget plugin let me know... Richard On Wed, Jan 30, 2013 at 11:59 PM, newbie wrote: > Hi > I m a newbie working on web2py,and i want to create an SQLForm > with database Employee.The fields of db.Employee are name,campus,timzezone > .I want the user to input in the SQLform ,but the last filed of timezone > shud be such that when the user inputs in the field ,it shud present a > dropdown of fields from another database called 'timezone_countries'.The > user shud be able to select from the dropdown and submit the form .The code > i have written in DB,Default,and view are here respectively:- > DB.py > db.define_table('Employee',Field('name'),Field('campus'),Field('timezone')) > > > db.define_table('timezone_countries',Field('countries')) > def timezone_countries_data(): > result = {} > result['countries'] = 'Brazil/Rio' > db.timezone_countries.insert(**result) > db.commit() > > DEFAULT.py > def timezone_countries_dataF(): > timezone_countries_data() > > def emp_input(): > form=SQLFORM(db.Employee) > return locals() > > def emp_selector(): > if not request.vars.emp_timezone: > --->where > emp_timezone is the id of timezone in SQLFORM > return ' ' > pattern = request.vars.emp_timezone.capitalize() + '%' > selected = [row.countries for row in > db(db.timezone_countries.countries.like(pattern)).select()] > return ''.join([DIV(k, > _onclick="jQuery('#emp_timezone').val('%s')" % k, > _onmouseover="this.style.backgroundColor='yellow'", > _onmouseout="this.style.backgroundColor='white'" > ).xml() for k in selected]) > > View: > {{extend 'layout.html'}} > {{=form}} > > #suggestions { position: relative; } > .suggestions { background: white; border: solid 1px #55A6C8; } > .suggestions DIV { padding: 2px 4px 2px 4px; } > > >class="suggestions"> > > > > jQuery("#emp_timezone").keyup(function(){ > ajax('emp_selector', ['emp_timezone'], 'suggestions')}); > > > > Kindly help... > > -- > > --- > 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. > > > -- --- 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.
[web2py] Create SQLFORM with one of its field's as ajax enabled
Hi I m a newbie working on web2py,and i want to create an SQLForm with database Employee.The fields of db.Employee are name,campus,timzezone .I want the user to input in the SQLform ,but the last filed of timezone shud be such that when the user inputs in the field ,it shud present a dropdown of fields from another database called 'timezone_countries'.The user shud be able to select from the dropdown and submit the form .The code i have written in DB,Default,and view are here respectively:- DB.py db.define_table('Employee',Field('name'),Field('campus'),Field('timezone')) db.define_table('timezone_countries',Field('countries')) def timezone_countries_data(): result = {} result['countries'] = 'Brazil/Rio' db.timezone_countries.insert(**result) db.commit() DEFAULT.py def timezone_countries_dataF(): timezone_countries_data() def emp_input(): form=SQLFORM(db.Employee) return locals() def emp_selector(): if not request.vars.emp_timezone: --->where emp_timezone is the id of timezone in SQLFORM return ' ' pattern = request.vars.emp_timezone.capitalize() + '%' selected = [row.countries for row in db(db.timezone_countries.countries.like(pattern)).select()] return ''.join([DIV(k, _onclick="jQuery('#emp_timezone').val('%s')" % k, _onmouseover="this.style.backgroundColor='yellow'", _onmouseout="this.style.backgroundColor='white'" ).xml() for k in selected]) View: {{extend 'layout.html'}} {{=form}} #suggestions { position: relative; } .suggestions { background: white; border: solid 1px #55A6C8; } .suggestions DIV { padding: 2px 4px 2px 4px; } jQuery("#emp_timezone").keyup(function(){ ajax('emp_selector', ['emp_timezone'], 'suggestions')}); Kindly help... -- --- 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.