This has changed in trunk.

On Tuesday, 27 November 2012 08:17:00 UTC-6, Cliff Kachinske wrote:
>
> Jim,
>
> I did discover one thing yesterday - this line of code hides the table 
> from smartgrid:
>
> db.supplier_contacts.supplier_id.readable=False
>
>
> Took out that line and the supplier_contacts link appeared in the grid.
>
> On Monday, November 26, 2012 4:12:22 PM UTC-5, Jim S wrote:
>>
>> Cliff
>>
>> In my table definition I use db.table_name just as in your example.  And 
>> in my controller I have a mixture of both, some where I specify the linked 
>> tables and some where I just let smartgrid figure it out.  Here is a sample 
>> model:
>>
>> benefitProgram = db.define_table('benefitProgram',
>>  Field('benefitProgramId', 'id', readable=False),
>>  Field('name', length=50, required=True, unique=True),
>>  format='%(name)s')
>> db.benefitProgram.name.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db, db.
>> benefitProgram.name)]
>> db.benefitProgram._plural = 'Benefit Programs'
>>
>> benefitLevel = db.define_table('benefitLevel',
>>  Field('benefitLevelId', 'id', readable=False),
>>  Field('benefitProgramId', db.benefitProgram, required=True, label='Benefit 
>> Program'),
>>  Field('name', length=50, required=True),
>>  format='%(name)s')
>> db.benefitLevel.benefitProgramId.requires = IS_IN_DB(db, db.
>> benefitProgram.benefitProgramId, '%(name)s', zero='..')
>> db.benefitLevel.name.requires = IS_NOT_EMPTY()
>> db.benefitLevel._plural = 'Benefit Levels'
>>
>>
>>
>>
>>
>> This works fine generating the smartgrid with links.
>>
>> -Jim
>>
>>
>> On Monday, November 26, 2012 2:52:57 PM UTC-6, Cliff Kachinske wrote:
>>>
>>> That alone is worth knowing.
>>>
>>> Do you identify the related tables using the db.tablename syntax or 
>>> 'reference tablename' syntax?
>>>
>>> Do you call the referencing id, for example, 'supplier_id', or just 
>>> 'supplier'?
>>>
>>> I'm guessing there's some subtle point I'm missing in my model files.
>>>
>>> On Monday, November 26, 2012 3:42:18 PM UTC-5, Jim S wrote:
>>>>
>>>> Sorry I don't have an answer for you but can confirm that linked_tables 
>>>> are working fine for me in 2.2.1.
>>>>
>>>> -Jim
>>>>
>>>> On Monday, November 26, 2012 12:06:49 PM UTC-6, Cliff Kachinske wrote:
>>>>>
>>>>> Smartgrid isn't picking up linked tables in V 2.2.1.  Could I be 
>>>>> missing something obvious?  Any suggestions gratefully accepted.
>>>>>
>>>>>
>>>>> Here are three tables from my model.
>>>>>
>>>>> db.define_table(
>>>>>     'suppliers',
>>>>>     Field('name', length=256, required=True, notnull=True),
>>>>>     Field('address', length=64),
>>>>>     Field('address_2', length=64),
>>>>>     # details omitted
>>>>>     .... 
>>>>>     )
>>>>>
>>>>>
>>>>> db.define_table(
>>>>>     'supplier_contacts',
>>>>>     Field('supplier_id', db.suppliers),
>>>>>     Field('first_name', length=32, required=True, notnull=True),
>>>>>     # details omitted
>>>>>     ...
>>>>>     )
>>>>>
>>>>>
>>>>> db.define_table('product_suppliers',
>>>>>                 Field('product_id', db.products),
>>>>>                 Field('supplier_id', db.suppliers),
>>>>>                 Field('lead_time', 'integer',     # details omitted
>>>>>     )
>>>>>
>>>>>
>>>>> The smartgrid from this controller code fails to contain a link to 
>>>>> supplier_contacts.  Worse, if I add a linked_tables argument the grid 
>>>>> displays no links at all.
>>>>>
>>>>> def smartindex():
>>>>>     form = SQLFORM.smartgrid(
>>>>>             db.suppliers,
>>>>> ##            linked_tables = [
>>>>> ##                db.supplier_contacts
>>>>> ##                ],
>>>>>             # links_in_grid=True,
>>>>>             # fields=[db.suppliers.name],
>>>>>             )
>>>>>     return dict(form=form)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>

-- 



Reply via email to