SQLFORM.grid search fields

33 views
Skip to first unread message

John Fraser

unread,
Apr 17, 2014, 11:48:33 AM4/17/14
to web...@googlegroups.com
How would one go about making certain fields readable (visible) to the search, view, edit, etc, but hidden from the actual grid.  Below is my code that accomplishes the hiding the fields from the main grid, but struggling with making them readable to the search:

@auth.requires_login()
def index():
    response.title = 'Computer Inventory'
    db.inventory.id.readable = False
    if 'view' in request.args or 'new' in request.args or 'edit' in request.args or '_export_type' in request.vars:
        db.inventory.gb_ram.readable = True
        db.inventory.hd_size.readable = True
        db.inventory.video_card.readable = True
        db.inventory.os_key.readable = True
        db.inventory.serial_service_code.readable = True
    else:
        db.inventory.gb_ram.readable = False
        db.inventory.hd_size.readable = False
        db.inventory.video_card.readable = False
        db.inventory.os_key.readable = False
        db.inventory.serial_service_code.readable = False
    if '_export_type' not in request.vars:
        db.inventory.cpu_status.represent = lambda cpu_status, row: \
            SPAN(row.cpu_status,
                 _style='text-transform: uppercase; font-weight: bold; padding:5px; color: %s; background-color: %s' %
                 ('black' if row.cpu_status == 'Staged' else 'white','red' if row.cpu_status == 'Repair' else 'gold'
                 if row.cpu_status == 'Staged' else 'green' if row.cpu_status == 'In Use' else 'black'))
    grid = SQLFORM.grid(db.inventory, csv=True, maxtextlengths={'inventory.notes': 65})
    return locals()


Thanks in advance!  Any help appreciated.
Reply all
Reply to author
Forward
0 new messages