For what it's worth, I have these modifications in my app to make Bootstrap
3 work with SQLFORM.grid:

In db.py:

def my_formstyle(form, fields):
    col_sm_label_size = 4
    col_md_label_size = 3
    form.add_class('form-horizontal col-sm-9 col-md-7 col-lg-5')
    label_col_class = "col-sm-%d col-md-%d" % (col_sm_label_size,
col_md_label_size)
    col_class = "col-sm-%d col-md-%d" % ((12 - col_sm_label_size), (12
- col_md_label_size))
    offset_class = "col-sm-offset-%d col-md-offset-%s" %
(col_sm_label_size, col_md_label_size)
    parent = CAT()
    for id, label, controls, help in fields:
        # wrappers
        _help = SPAN(help, _class='help-block')
        # embed _help into _controls
        _controls = DIV(controls, _help, _class=col_class)
        if isinstance(controls, INPUT):
            if controls['_type'] == 'submit':
                controls.add_class('btn btn-primary')
                _controls = DIV(controls, _class="%s %s" % (col_class,
offset_class))
            if controls['_type'] == 'button':
                controls.add_class('btn btn-default')
            elif controls['_type'] == 'file':
                controls.add_class('input-file')
            elif controls['_type'] == 'text':
                controls.add_class('form-control')
            elif controls['_type'] == 'email':
                controls.add_class('form-control')
            elif controls['_type'] == 'password':
                controls.add_class('form-control')
            elif controls['_type'] == 'checkbox':
                label['_for'] = None
                label.insert(0, controls)
                _controls = DIV(DIV(label, _help, _class="checkbox"),
                            _class="%s %s" % (offset_class, col_class))
                label = ''
            elif isinstance(controls, SELECT):
                controls.add_class('form-control')
            elif isinstance(controls, TEXTAREA):
                controls.add_class('form-control')

        elif isinstance(controls, SPAN):
            _controls = P(controls.components,
_class="form-control-static %s" % col_class)

        if isinstance(label, LABEL):
            label['_class'] = 'control-label %s' % label_col_class

        parent.append(DIV(label, _controls, _class='form-group', _id=id))
    return parent

grid_ui = dict(widget='',
               header='',
               content='',
               default='',
               cornerall='',
               cornertop='',
               cornerbottom='',
               button='btn btn-default button',
               buttontext='buttontext button',
               buttonadd='glyphicon glyphicon-plus space-after',
               buttonback='glyphicon glyphicon-arrow-left space-after',
               buttonexport='glyphicon glyphicon-download space-after',
               buttondelete='glyphicon glyphicon-trash space-after',
               buttonedit='glyphicon glyphicon-pencil space-after',
               buttontable='glyphicon glyphicon-arrow-right space-after',
               buttonview='glyphicon glyphicon-zoom-in space-after')


Then I pass along to my SQLFORM.grid calls like this:

In my controllers:

grid = SQLFORM.grid(query, fields=fields, orderby=orderby,
                    create=create, details=details,
                    editable=editable, deletable=deletable,
                    csv=False, search_widget=defaultSearch,
                    paginate=15, maxtextlength=45,
                    formstyle = my_formstyle, ui=grid_ui)


This works well with my site, you may need to tweak it to get your site
looking nice.  By no means is this something that will work universally.

-Jim



On Mon, Nov 24, 2014 at 8:33 AM, Anthony <[email protected]> wrote:

> I think the relevant BS3 functionality is there. The only thing we don't
> have is a BS3 based scaffolding app, but if you're using a custom theme,
> the scaffolding app probably wouldn't help much anyway.
>
> Anthony
>
>
> On Monday, November 24, 2014 2:39:58 AM UTC-5, Tom Øyvind Hogstad wrote:
>>
>> No particular problem. More of a wondering what happened to this
>> "project".
>>
>> Since this is my first web2py project, never used Bootstrap, I also had
>> almost zero knowledge of Python, never really used PostgreSQL and my VPSes
>> have always been Centos, but I felt for Debian on my latest VPS. 200+ hours
>> later I need to set aside some time to refactor stuff :-)
>> Selling in projects without being proficient in any of the tech you wan't
>> to use, lead to loads of fun (And a bit on the low side considering "real"
>> hourly rate) :-)
>>
>> Mostly wan't to use BS3 trying to consolidate theming to BS3 for both
>> Web2py and Drupal work.
>> Going for reworking my app to BS3.
>>
>> Tom Ø.
>>
>>
>>
>> kl. 18:22:13 UTC+1 søndag 23. november 2014 skrev Anthony følgende:
>>>
>>> You can use web2py with Bootstrap 3 (or any front end framework). It
>>> even has built-in formstyles and grid classes for Bootstrap 3 (though even
>>> without those, you can add your own custom formstyles and grid classes). Is
>>> there a particular problem you are having?
>>>
>>> Anthony
>>>
>>> On Sunday, November 23, 2014 8:00:13 AM UTC-5, Tom Øyvind Hogstad wrote:
>>>>
>>>> What is the status of bootstrap3 now.
>>>> It was reverted in trunc and I just started a project at that time.
>>>> Started in bootstrap3, but I had not done much so I reverted to bootstrap2.
>>>> Now I would like to go back/forward to bootstrap3 again before my
>>>> project gets any larger.
>>>>
>>>> Tom Ø.
>>>>
>>>>
>>>>
>>>> kl. 09:13:38 UTC+2 lørdag 9. august 2014 skrev Massimo Di Pierro
>>>> følgende:
>>>>>
>>>>> Bootstrap 3 is in trunk now. Please help us test it.
>>>>> Also help us test that existing apps are not broken.
>>>>>
>>>>> Massimo
>>>>>
>>>>  --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/HWZ_4gyUSPo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.

Reply via email to