I've been playing with SQLFORM.smartgrid for the past couple of days and have a few issues I'd like to talk about. Some of them I consider bugs and others are just some nice things that I think could be added easily.

For the purpose of a couple of these explanations, you'd need to see my model/controller, so here are the relevant parts:

######  db.py

member = db.define_table('member',
    Field('memberId', 'id'),
    Field('firstName', length=100, required=True, label='First Name'),
    Field('middleInitial', length=20, label='Middle Initial'),
    Field('lastName', length=50, required=True, label='Last Name'),
    Field('secondFirstName', length=50, label='Second First Name'),
    Field('secondLastName', length=50, label='Second Last Name'),
    Field('householdSalutation', length=50, label='Household Salutation'),
    Field('householdFirstName', length=50, label='Household First Name'),
    Field('businessName', length=128, label='Business Name'),
    Field('address', 'text'),
    Field('city', length=50),
    Field('state', length=2),
    Field('postalCode', length=10, label='Postal Code'),
    Field('homePhone', length=25, label='Home Phone'),
    Field('email', length=255),
Field('legaciesBequests', 'decimal(11,2)', label='Legacies and Bequests'),
    Field('notes', 'text'),
    Field('joinedOn', 'date', label='Joined On',
          default=datetime.date.today(),
          requires=IS_DATE(format='%m/%d/%Y'),
          represent=lambda value, x: value.strftime('%m/%d/%Y')),
    Field('deceased', 'boolean', default=False), fake_migrate=True,
    migrate=False, format='%(firstName)s %(lastName)s')

member.firstName.requires = IS_NOT_EMPTY()
member.lastName.requires = IS_NOT_EMPTY()

tag = db.define_table('tag',
    Field('tagId', 'id'),
    Field('name', length=50, required=True, unique=True),
    format='%(name)s')

tag.name.requires = [IS_NOT_EMPTY(),
                     IS_NOT_IN_DB(db, 'tag.name')]

memberTag = db.define_table('memberTag',
    Field('memberTagId', 'id', label='ID'),
    Field('memberId', db.member, required=True, label='Member'),
Field('tagId', db.tag, required=True, label='Tag'), migrate=True, fake_migrate=True)

memberTag.memberId.requires = IS_IN_DB(db, db.member.id,
                                    '%(firstName)s %(lastName)s',
                                    zero=('select member'))
memberTag.tagId.requires = IS_IN_DB(db, db.tag.id,
                                    '%(name)s', zero=('select tag'))
memberTag.tagId.represent = lambda t, r: db.tag(t).name
memberTag.memberId.represent = lambda m, r: '%s %s' % (db.member(m).firstName, db.member(m).lastName)

######  default.py
def members():
    response.view = 'list.html'
    columns = ['member.firstName', 'member.lastName', 'member.city',
               'member.state', 'member.phone', 'member.joinedOn',
               'memberCampaign.campaignId',
               'memberCampaign.amount', 'memberCampaign.paidOn',
               'memberTag.tagId']
    grid = SQLFORM.smartgrid(db.member, columns=columns, details=False)
    return dict(grid=grid)


1. When using jquery-ui (ui-lightness in my case) the icons on all of the buttons are lost. 2. When clicking on the memberTag button in the member grid I go to a page to edit the member tags. Above my grid are three buttons, labeled:

member
Jim Steil
memberTag

If I click on the member button it takes me back to the member grid. If I click on the 'Jim Steil' button it will return me to the 'view' page unless it is disabled, then it returns me to the member grid page. In my scenario I'd like it to return me to the member 'edit' page because I have the details=False set on my smartgrid.

3. For these buttons that appear across the top I'd like to be able to control their names in some way. It appears that I can override all of the buttons with the links parameter on the smartgrid setup, but I was hoping to find a way to more easily (less boilerplate code) accomplish that. 4. In the grid first displayed by the smartgrid I'd like a way to control the text that appears on the memberTag button. 5. Using jquery-ui (ui-lightness) I can't tell which page I'm currently on looking at the page navigation buttons at the bottom of the grid. The current page should be set off in some way to give an indication of the current page. 6. Allow initial grid sort sequence to be applied to smartgrid via orderby parameter. Also allow initial ordering of subsequent grid (memberTag).

The smartgrid is an incredibly powerful tool that will allow me to create web applications very quickly. I'd like to get these items discussed to see if the community thinks they are worth while.

Thanks for taking the time to read through this long post. If it would be helpful I could put together my entire app and put it out for others to use to comment on the smartgrid functionality as well.

    -Jim


Reply via email to