Re: [web2py] Re: SQLFORM grid and smartgrid
I'm using the new format of the google group and see them as attachments at the bottom of the post. I can create new ones if that helps? -Jim On 9/14/2011 10:07 PM, Massimo Di Pierro wrote: I do not see the screenshot. :-( This should work, although may not work the way you want. On Sep 14, 4:48 pm, Jim Steilj...@qlf.com wrote: In response to #3, I see what is going on now. I'm working on a membership database where I have the following model: ### db.py member = db.define_table('member', Field('memberId', 'id'), Field('firstName', length=50, 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)) member.firstName.requires = IS_NOT_EMPTY() member.lastName.requires = IS_NOT_EMPTY() campaign = db.define_table('campaign', Field('campaignId', 'id'), Field('name', length=50, required=True, unique=True), Field('start', 'date', required=True, default=datetime.date.today(), requires=IS_DATE(format='%m/%d/%Y'), represent=lambda value, x: formatDate(value)), Field('end', 'date', requires=IS_NULL_OR(IS_DATE(format='%m/%d/%Y')), represent=lambda value, x: formatDate(value), )) campaign.name.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db, 'campaign.name')] memberCampaign = db.define_table('memberCampaign', Field('memberId', db.member, required=True, label='Member'), Field('campaignId', db.campaign, required=True, label='Campaign'), Field('amount', 'decimal(13,2)'), Field('paidOn', 'date', label='Paid On', default=datetime.date.today().strftime('%m/%d/%Y'), requires=IS_DATE(format='%m/%d/%Y'), represent=lambda value, x: value.strftime('%m/%d/%Y'))) memberCampaign.memberId.requires = IS_IN_DB(db, db.member.id, '%(firstName) %(lastName)s', zero=('select member')) memberCampaign.campaignId.requires = IS_IN_DB(db, db.campaign.campaignId, '%(name)s', zero=('select campaign')) tag = db.define_table('tag', Field('tagId', 'id'), Field('name', length=50, required=True, unique=True)) tag.name.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db, 'tag.name')] memberTag = db.define_table('memberTag', Field('memberId', db.member, required=True, label='Member'), Field('tagId', db.tag, required=True, label='Tag')) memberTag.memberId.requires = IS_IN_DB(db, db.member.id, '%(firstName) %(lastName)s', zero=('select member')) memberTag.tagId.requires = IS_IN_DB(db, db.tag.id, '%(name)s', zero=('select tag')) ## and the following controller ## default.py def members(): columns = ['member.firstName', 'member.lastName', 'member.city', 'member.state', 'member.phone', 'member.joinedOn', 'member.deceased'] orderBy = ['member.lastName'] grid = SQLFORM.smartgrid(db.member, columns=columns, details=False) return dict(grid=grid) ## Here are screen shots of the progression through it: Click on memberTag Click on Add Not sure what this all means as I'm not sure of the intent of the SQLFORM.smartgrid(). But, I was assuming (yes I know that's bad) that it would create an entry form for me with the default member already selected. Would be fantastic if this worked. If it is a while out, I will go ahead and create some custom views to do this, but if it could work, that would be fantastic. Any thoughts? -Jim On 9/14/2011 11:01 AM, Jim Steil wrote: I understand that these two grid are brand new, but has anyone created any documentation on all of the options and how to use them yet? Here are a couple issues
Re: [web2py] Re: SQLFORM grid and smartgrid
Ok, found the problem. I was missing an 's' in the line: memberTag.memberId.requires = IS_IN_DB(db, db.member.id, '%(firstName) %(lastName)s', zero=('select member')) Should have been: memberTag.memberId.requires = IS_IN_DB(db, db.member.id, '%(firstName)s %(lastName)s', zero=('select member')) I duplicated the problem with the memberCampaign table as well. Now I'm running into another issue and. As you noticed in the members method in the default.py controller, I'm specifying the fields to be displayed in my member grid. When I get to the memberCampaign grid, no columns are displaying for the memberCampaign table. I see the buttons for the rows that are there, but no other columns. I'm assuming that is because it is using the columns specified on the main smartgrid. So, I added the memberCampaign columns to that list and tried again. No luck. The grid shows a row, but no columns other than the buttons. Very impressed with this. It is incredibly powerful stuff. -Jim On 9/14/2011 10:19 PM, Jim Steil wrote: I'm using the new format of the google group and see them as attachments at the bottom of the post. I can create new ones if that helps? -Jim On 9/14/2011 10:07 PM, Massimo Di Pierro wrote: I do not see the screenshot. :-( This should work, although may not work the way you want. On Sep 14, 4:48 pm, Jim Steilj...@qlf.com wrote: In response to #3, I see what is going on now. I'm working on a membership database where I have the following model: ### db.py member = db.define_table('member', Field('memberId', 'id'), Field('firstName', length=50, 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)) member.firstName.requires = IS_NOT_EMPTY() member.lastName.requires = IS_NOT_EMPTY() campaign = db.define_table('campaign', Field('campaignId', 'id'), Field('name', length=50, required=True, unique=True), Field('start', 'date', required=True, default=datetime.date.today(), requires=IS_DATE(format='%m/%d/%Y'), represent=lambda value, x: formatDate(value)), Field('end', 'date', requires=IS_NULL_OR(IS_DATE(format='%m/%d/%Y')), represent=lambda value, x: formatDate(value), )) campaign.name.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db, 'campaign.name')] memberCampaign = db.define_table('memberCampaign', Field('memberId', db.member, required=True, label='Member'), Field('campaignId', db.campaign, required=True, label='Campaign'), Field('amount', 'decimal(13,2)'), Field('paidOn', 'date', label='Paid On', default=datetime.date.today().strftime('%m/%d/%Y'), requires=IS_DATE(format='%m/%d/%Y'), represent=lambda value, x: value.strftime('%m/%d/%Y'))) memberCampaign.memberId.requires = IS_IN_DB(db, db.member.id, '%(firstName) %(lastName)s', zero=('select member')) memberCampaign.campaignId.requires = IS_IN_DB(db, db.campaign.campaignId, '%(name)s', zero=('select campaign')) tag = db.define_table('tag', Field('tagId', 'id'), Field('name', length=50, required=True, unique=True)) tag.name.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db, 'tag.name')] memberTag = db.define_table('memberTag', Field('memberId', db.member, required=True, label='Member'), Field('tagId', db.tag, required=True, label='Tag')) memberTag.memberId.requires = IS_IN_DB(db, db.member.id, '%(firstName) %(lastName)s', zero=('select member')) memberTag.tagId.requires
Re: [web2py] Re: SQLFORM grid and smartgrid
Again, found to be a typo on my end. I should give it up for the night -Jim On 9/15/2011 12:12 AM, Jim Steil wrote: Ok, found the problem. I was missing an 's' in the line: memberTag.memberId.requires = IS_IN_DB(db, db.member.id, '%(firstName) %(lastName)s', zero=('select member')) Should have been: memberTag.memberId.requires = IS_IN_DB(db, db.member.id, '%(firstName)s %(lastName)s', zero=('select member')) I duplicated the problem with the memberCampaign table as well. Now I'm running into another issue and. As you noticed in the members method in the default.py controller, I'm specifying the fields to be displayed in my member grid. When I get to the memberCampaign grid, no columns are displaying for the memberCampaign table. I see the buttons for the rows that are there, but no other columns. I'm assuming that is because it is using the columns specified on the main smartgrid. So, I added the memberCampaign columns to that list and tried again. No luck. The grid shows a row, but no columns other than the buttons. Very impressed with this. It is incredibly powerful stuff. -Jim On 9/14/2011 10:19 PM, Jim Steil wrote: I'm using the new format of the google group and see them as attachments at the bottom of the post. I can create new ones if that helps? -Jim On 9/14/2011 10:07 PM, Massimo Di Pierro wrote: I do not see the screenshot. :-( This should work, although may not work the way you want. On Sep 14, 4:48 pm, Jim Steilj...@qlf.com wrote: In response to #3, I see what is going on now. I'm working on a membership database where I have the following model: ### db.py member = db.define_table('member', Field('memberId', 'id'), Field('firstName', length=50, 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)) member.firstName.requires = IS_NOT_EMPTY() member.lastName.requires = IS_NOT_EMPTY() campaign = db.define_table('campaign', Field('campaignId', 'id'), Field('name', length=50, required=True, unique=True), Field('start', 'date', required=True, default=datetime.date.today(), requires=IS_DATE(format='%m/%d/%Y'), represent=lambda value, x: formatDate(value)), Field('end', 'date', requires=IS_NULL_OR(IS_DATE(format='%m/%d/%Y')), represent=lambda value, x: formatDate(value), )) campaign.name.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db, 'campaign.name')] memberCampaign = db.define_table('memberCampaign', Field('memberId', db.member, required=True, label='Member'), Field('campaignId', db.campaign, required=True, label='Campaign'), Field('amount', 'decimal(13,2)'), Field('paidOn', 'date', label='Paid On', default=datetime.date.today().strftime('%m/%d/%Y'), requires=IS_DATE(format='%m/%d/%Y'), represent=lambda value, x: value.strftime('%m/%d/%Y'))) memberCampaign.memberId.requires = IS_IN_DB(db, db.member.id, '%(firstName) %(lastName)s', zero=('select member')) memberCampaign.campaignId.requires = IS_IN_DB(db, db.campaign.campaignId, '%(name)s', zero=('select campaign')) tag = db.define_table('tag', Field('tagId', 'id'), Field('name', length=50, required=True, unique=True)) tag.name.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db, 'tag.name')] memberTag = db.define_table('memberTag', Field('memberId', db.member, required=True, label='Member'), Field('tagId', db.tag, required=True, label='Tag')) memberTag.memberId.requires = IS_IN_DB(db, db.member.id,