Reputation: 1691
How do I modify the edit view in my SQLFORM.grid - size of input fields, drip down menus, etc. Documentation is poorly written so any examples would be a big help. Thank you
Upvotes: 3
Views: 1311
Reputation: 435
The SQLFORM.grid uses the assigned widgets in your database model. So to change the output of the grid on widget level, change the model. The fieldtype defines the auto selected widget. See the field-constructors part of the book.
If you want more fine-grained control over the result you could tweak the widgets, override widgets, create your own widgets, patch the generated code in the browser using jquery of choose to write the entire grid yourself. Also you could change some parameters to the grid based on some SQLFORM parameters it passed through to the generated SQLFORM. Try the viewargs
argument to the grid to alter the parameters sent to the SQLFORM when viewing. You might want to offer it something like dict(formstyle='divs')
or use the ui
parameter to offer a dictionary with classnames you use to apply your own CSS. ref
About the choice for using the grid in the first place:
These are two high level objects that create complex CRUD controls. They provide pagination, the ability to browse, search, sort, create, update and delete records from a single object.
So for very fine grained control it might be best to write your own grid instead of using such high level objects.
I'm not saying it's impossible to finetune the grid using the model and some javascript, but because it uses so much of all the other elements of web2py diving into the grid without much further web2py knowledge is quite a steep learning curve.
Upvotes: 1