I've been experimenting with this (see this for example 
http://www.web2pyslices.com/slice/show/1928/basic-inline-editing-in-sqlformgrid-no-plugin-method)
The slice shows how to add a submit button, process the submit and also how 
to use web2py widgets to make grid elements in-line editable.

Regarding submit buttons: the grid has forms. You can add a submit button 
with web2py helpers, but it won't work because browsers see nested forms, 
and they basically reject a submit button added after the grid. 

However, you can make a separate form with nothing it it except a submit 
button, and user your view to display it immediately after your grid.
Better though is to use the SQLFORM.grid 'selectable' keyword to get a 
submit button. You'll end up with checkboxes per row; if you don't want 
those, have a look at my slice to see how to remove them.  This submit 
button is part of the grid and therefore should give you no styling issues.


On Wednesday, 1 January 2014 05:33:23 UTC+11, Kyle Flanagan wrote:
>
> I'm using a table to hold temporary information from a user. I use 
> SQLFORM.grid to present this table. What I'd like to do is add a submit 
> button below the table that calls my submit function.
>
> If I try adding an extra element in the controller according to the book (
> http://web2py.com/book/default/chapter/07#Adding-extra-form-elements-to-SQLFORM)
>  
> I get the element added to the form, but it's at the top of the grid, not 
> the bottom. (Also, I'm not even sure if this is a documented feature since 
> the documentation is for SQLFORM, not SQLFORM.grid.)
>
>     grid = SQLFORM.grid(
>                         mydbquery,
>                         fields=fields,
>                         searchable=False,
>                         create=False,
>                         editable=False,
>                         details=False
>                         )
>     my_extra_element = TR(LABEL('Click to submit'),                       
>                           
> INPUT(_name='submit',value="Submit",_type='submit'))
>     grid[0].insert(-1,my_extra_element)
>
>
> On top of that, the styling is different...not sure what formstyle 
> SQLFORM.grid uses. 
>
> So, my question is twofold:
>
> 1) Is it possible to have an element added below SQLFORM.grid instead of 
> at the top?
> 2) How can I have the inserted element (in this case, a button) match the 
> styling of SQLFORM.grid?
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to