Hello,
I could sort it out...
For those who could be interrested, here under the key elements of my
solution.
1. In the model, create the following functions (here for string and drop
list):
def options_widget(field,value,**kwargs):
return
SQLFORM.widgets.options.widget(field,value,_class="generic-widget",**kwargs)
def string_widget(field,value,**kwargs):
return
SQLFORM.widgets.string.widget(field,value,_class='string',**kwargs )
In the controller, in the function that you want to contain the editing
grid:
def my_function_name(): # here my tale name = t_txw_expense_template
if len(request.post_vars) >0:
for key, value in request.post_vars.iteritems():
(field_name,sep,row_id) = key.partition('_row_') # field_name
will look like field_name_row_99
if row_id:
db(db.t_txw_expense_template.id ==
row_id).update(**{field_name:value})
# the name of the attribute is used to know which row is involved
# for each field that you want to see:
db.t_txw_expense_template.f_expense_template.represent = lambda value,
row: string_widget(db.t_txw_expense_template.f_expense_template, value,
**{'_name':'f_expense_template_row_%s' % row.id})
db.t_txw_expense_template.f_header.represent = lambda value, row:
string_widget(db.t_txw_expense_template.f_header, value,
**{'_name':'f_header_row_%s' % row.id})
db.t_txw_expense_template.f_project.represent = lambda value, row:
options_widget(db.t_txw_expense_template.f_project, value,
**{'_name':'f_project_row_%s' % row.id})
# and so on...
form = SQLFORM.smartgrid(db.t_txw_expense_template, # and so on...
# selectable = dict(t_txw_expense_template=
None)
selectable= lambda ids :
redirect(URL('my_function_name',vars=request._get_vars)),
)
#remove selectable's checkboxes
form.elements(_type='checkbox',_name='records',replace=None)
return dict (form = form)
Hope this can help...
Le jeudi 17 juillet 2014 21:57:12 UTC+2, Anthony a écrit :
>
> I don't have time to look into it, but seeing some code and a traceback
> might help.
>
> Anthony
>
> On Thursday, July 17, 2014 12:18:39 PM UTC-4, Serge Bourgeois wrote:
>>
>> Thanks Antony!. Do you know if there is any plan to develop such a
>> feature? If yes, do you have any idea of availability ?
>>
>> Still a third question: I tried the idea proposed here :
>>
>>
>> http://www.web2pyslices.com/slice/show/1928/basic-inline-editing-in-sqlformgrid-no-plugin-no-javascript
>>
>> but, I got a message saying that I couldn't change the objects already
>> existing ... (I guess the name of the fields, even with migrate == False).
>>
>> Maybe you have any good idea to turn around this issue?
>>
>> Serge
>>
>>
>> Le jeudi 17 juillet 2014 17:21:05 UTC+2, Anthony a écrit :
>>>
>>> This is not available out of the box, though it would be nice.
>>>
>>> Anthony
>>>
>>> On Thursday, July 17, 2014 10:25:20 AM UTC-4, Serge Bourgeois wrote:
>>>>
>>>> Hello,
>>>>
>>>> In order to simplify the user interface of basic controller functions,
>>>> I want to offer direct editing in SQLFORM.smartgrid, using the same
>>>> widgets
>>>> (string, options, uploads, ...) than those available in create or edit.
>>>>
>>>> Maybe, I missed the point in the doc?
>>>>
>>>> Thank you for any advice.
>>>>
>>>> Serge
>>>>
>>>>
--
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/d/optout.