web2py: Replace Smartgrid standard delete button

2019-08-25 03:03发布

问题:

I wanted to replace the standard delete button in Smartgrid. Here's what I attempted to do:

def list_service_types():
    grid = SQLFORM.smartgrid(db.service_types
        , fields = [db.service_types.type_name, db.services.service_name]
        , ondelete = ondelete_service_type
        , links = [lambda row: A('Delete', _href='#', _glyph="icon-trash", _class="button btn btn-secondary", )]
        )
    return locals()

Problems:

1) I can't get the icon-trash glyph/icon to display
2) How do I position the new button at the end of the row, eventually replacing the standard delete button

Screen shot follows:

Edit 1
I managed to make the glyph show with the following links:

    , links = [lambda row: A('Delete', _href='#', _class="button btn btn-secondary icon trash icon-trash glyphicon glyphicon-trash", )]

but the font and spacing are off. I can see from the page source that <span> tags must be in place, like the following:

<span class="icon trash icon-trash glyphicon glyphicon-trash"></span>

but I dont know how to proceed.

Screenshot follows:

标签: python web2py