It's not necessary modify the code in gluon.
You could replace the text input in the query panel. For example:
1) in db.py we define our table
db.define_table('contact',
Field('name'),
Field('phone'))
2) in default.py we define our controller to create the grid
def contacts():
grid=SQLFORM.grid(db.contact, user_signature=False)
table_name = 'contact'
field_name = 'phone'
element_id = 'w2p_value_%s-%s' % (table_name, field_name)
custom_select = SELECT('', 'value1', 'value2', 'value3', _id=element_id)
grid.element('input',_id=element_id, replace=custom_select)
return locals()
3) we create our view default/contacts.html
{{extend 'layout.html'}}
<h1>Manage My Contacts</h1>
{{=grid}}
The code in step2 should put you on the right way.
Il giorno venerdì 25 ottobre 2013 13:57:21 UTC+2, Sarbjit ha scritto:
>
> I was looking at the code in gucon.sqlform
>
> elif (field.type.startswith('reference ') or
> field.type.startswith('list:reference ')) and \
> hasattr(field.requires,'options'):
> value_input = SELECT(
> *[OPTION(v, _value=k)
> for k,v in field.requires.options()],
> **dict(_id=_id))
> elif field.type == 'integer' or \
> field.type.startswith('reference ') or \
> field.type.startswith('list:integer') or \
> field.type.startswith('list:reference '):
> value_input =
> SQLFORM.widgets.integer.widget(field,field.default,_id=_id)
> else:
> value_input = INPUT(
> _type='text', _id=_id, _class=field.type)
>
>
> Can this be enhanced to view Selection Dropdown with the values for all
> the fields. I have not much experience in web2py, so can some one please
> suggest a change here.
>
> On Wednesday, October 23, 2013 9:01:23 AM UTC+5:30, Sarbjit wrote:
>>
>> Can someone please help.
>>
>> On Tuesday, October 22, 2013 4:39:00 PM UTC+5:30, Sarbjit wrote:
>>>
>>> I am using GRID for displaying my database results. I want to use search
>>> feature provided by GRID/SMARTGRID where users can build queries and get
>>> the results. I want to have a drop down field populated with the values
>>> defined in the database for the fields which are defined as strings in
>>> database.
>>>
>>> In my case, some fields needs to have exact match and are used very
>>> frequent for searching the records. Since it is very difficult to fill in
>>> the exact name every time you are searching the records using that field, I
>>> want that for few fields, it should present a drop down.
>>>
>>> Can some one please suggest me on how on to do this.
>>>
>>> Thanks
>>> Sarbjit
>>>
>>
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.