Adding search and insert in text input

45 views
Skip to first unread message

Phil Hughes

unread,
Apr 3, 2015, 9:16:39 AM4/3/15
to web...@googlegroups.com
I have a table with a text area. I want to be able to insert a clickable reference to a a record in another table while entering/editing the text. Ideally, I should be able to search the table I want to reference to find the entry I want to point to. I am sure I can do this with AJAX but, well, AJAX is not my forte.

Here is a more detailed description -- not what I am doing but easier to explain.

Let's say the table I want to reference is colors and the table I am editing describes cars. I want to be able to enter text such as "This car is <blue>" where blue would be a a clickable reference into the color table. Clearly easy if the color table is short but what I will reference will eventually have thousands of records. Thus, the need for the search.

Clues and/or examples appreciated. Thanks.

Ron Chatterjee

unread,
Apr 3, 2015, 9:21:40 PM4/3/15
to web...@googlegroups.com
Read the cookbook for web2py. I believe its chapter 4

黄祥

unread,
Apr 7, 2015, 8:14:49 AM4/7/15
to web...@googlegroups.com
i think you can use represent on this 
e.g.
for reference link :
db.employee.bank.represent = lambda bank, field: \
A(bank.bank, _title=T("eBanking"), _target="_blank", _href="%s" % bank.ebanking) if bank else ''

for colored value
db.product.status.represent = lambda status, field: SPAN(product_status[status], _class = 'text-success' if status == 'Sold' else 'text-warning' if status == 'Hold' else 'text-error')

best regards,
stifan
Reply all
Reply to author
Forward
0 new messages