Found a solution, posting it here that others may have reference for
toscawidgets2 autocompletewidget
Here is the solution:
@expose()
def optionsStates(self,**kw):
print 'here>>', kw
stateList = DBSession.query(StateCountyRecDate).all()
statecounty = []
for j in stateList:
if j.stateCounty not in statecounty:
statecounty.append(j.stateCounty)
val = json.JSONEncoder().encode(statecounty)
return (val)
On Saturday, February 16, 2013 2:57:00 PM UTC+8, Carlos Daniel Ruvalcaba
Valenzuela wrote:
>
> Check the documentation carefully, the returning dict in your code has
> a key called term while the docs has one called data:
>
> http://turbogears.org/2.0/docs/main/ToscaWidgets/Cookbook/AutoComplete.html
>
> Change your returning dict key from term to data and see how it goes.
>
> Regards,
> Carlos Ruvalcaba
>
> On Fri, Feb 15, 2013 at 11:47 PM, Neil Ablang
> <[email protected]<javascript:>>
> wrote:
> > Hello,
> >
> > I am trying to make the autocompletewidget work for 2days but of no
> > success.
> >
> > On my widget folder I have this:
> >
> > class StateCountyForm(FormPage):
> > resources = [CSSLink(link='/css/forms.css')]
> > title='Select State - County Pair'
> > class child(TableForm):
> > options={'source':'optionsStates'}
> > action ='/list_all_notclassified/'
> > buttons =[SubmitButton,ClearButton]
> > StateCounty = AutocompleteWidget(options=options)
> >
> > On my root.py , I have a controller method:
> >
> > @expose('json')
> > def optionsStates(self,**kw):
> > print 'here>>', kw
> > stateList = DBSession.query(StateCountyRecDate).all()
> > statecounty = []
> > for j in stateList:
> > if j.stateCounty not in statecounty:
> > statecounty.append(j.stateCounty)
> >
> > return dict(term=statecounty)
> >
> > I can see that url optionsState is responding, like if i type 'c' on the
> > form, i can see the print output
> >
> > here>> {'term': u'c'}
> >
> > The problem is, the form is not getting back the list of options to
> select
> > from.
> >
> > How to send back the results to the AutocompleteWidget? I read the
> values
> > to send back should in json format
> >
> > I appreciate any help
> >
> > Thanks in advance
> >
> > Neil
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups
> > "TurboGears" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an
> > email to [email protected] <javascript:>.
> > To post to this group, send email to
> > [email protected]<javascript:>.
>
> > Visit this group at http://groups.google.com/group/turbogears?hl=en.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.