But, I'm linking 3 tables using the 'left' argument. It is getting the id
from the last linked table.
open_feed_orders = db((((db.feedOrder.invoiceNumber == None) |
(db.feedOrder.invoiceNumber == 0)) &
db.feedOrder.siteId == site_id))._select(db.
feedOrder.feedOrderId)
used_feed_order_lines = db(db.workorder_finish.id > 0)._select(db.
workorder_finish.feed_order_line)
queries = [db.feedOrderLine.feedOrderLineId > 0]
queries.append(db.feedOrderLine.feedOrderId.belongs(open_feed_orders))
queries.append(~db.feedOrderLine.feedOrderLineId.belongs(
used_feed_order_lines))
queries.append(db.feedOrder.siteId == site_id)
queries.append(db.feedLoad.deliverOn>=from_date)
queries.append(db.feedLoad.deliverOn<=to_date)
queries.append(~db.feedOrderLine.productNumber.belongs(['I00255',
'I00279','I00280','I00289']))
query = reduce(lambda a, b: (a & b), queries)
orderby = [db.feedOrderLine.productNumber, db.feedOrderLine.productName]
left = [db.feedOrder.on(db.feedOrderLine.feedOrderId == db.feedOrder.
feedOrderId),
db.feedLoad.on(db.feedOrder.feedLoadId == db.feedLoad.feedLoadId
)]
fields = [db.feedLoad.deliverOn,
db.feedOrder.orderNumber,
db.feedLoad.loadNumber,
db.feedOrderLine.productNumber,
db.feedOrderLine.productName,
db.feedOrderLine.quantityOrdered,
db.feedOrderLine.feedOrderLineId]
grid = SQLFORM.grid(query,fields=fields,create=False,editable=False,
details=False,deletable=False,csv=False,
searchable=False, orderby=orderby, left=left,
selectable=lambda ids:redirect(URL('workorder',
'new_from_sales_order_confirm',
vars=dict(ids=ids)),
client_side=True),
maxtextlength=256,paginate=256, formstyle=
my_formstyle, ui=grid_ui)
It is bringing the ID field from the feedLoad table. I want the id from
the feedOrderLine table. Also, I've tried changing the order of the fields
in my 'fields' list to have one from feedOrderLine first, but it doesn't
care.
-Jim
On Monday, October 13, 2014 2:24:22 PM UTC-5, Niphlod wrote:
>
> I'm assuming it gets the quite-obvious field_id parameter. If none, it
> just gets the first 'id' field of the first table in the join.
>
> On Monday, October 13, 2014 5:38:51 PM UTC+2, Jim S wrote:
>>
>> I see this was never answered, but I'm looking for the same thing. How
>> does SQLFORM.grid's 'selectable' determine which field to use for the
>> 'ids'? I have a left join as well, and it is picking the 'id' field from
>> the wrong table. Is there a way to specify which table to use?
>>
>> -Jim
>>
>> On Monday, March 12, 2012 7:41:18 AM UTC-5, Johann Spies wrote:
>>>
>>> When using the following grid:
>>>
>>> query = ((db.akb_authors.id.belongs(ids))&
>>> (db.akb_authors_article_link.author == db.akb_authors.uuid)&
>>> (db.akb_authors_article_link.article ==
>>> db.akb_articles.uuid)&
>>> (db.akb_journal.uuid == db.akb_articles.journal))
>>> left = (db.akb_authors_article_link.on((db.akb_authors.uuid ==
>>> db.akb_authors_article_link.author)&
>>> (db.akb_authors.id.belongs(ids))&
>>> (db.akb_authors_article_link.author == db.akb_authors.uuid)&
>>> (db.akb_authors_article_link.article ==
>>> db.akb_articles.uuid)&
>>> (db.akb_journal.uuid == db.akb_articles.journal)))
>>> fields = [db.akb_authors.id, db.akb_authors.surname,
>>> db.akb_authors.firstname,
>>> db.akb_authors.name, db.akb_authors.birthdate,
>>> db.akb_authors.gender,
>>> db.akb_authors.race, db.akb_authors.address,
>>> db.akb_journal.title,
>>> db.akb_journal.subject ]
>>> headers = {'akb_journal.title': 'Journal'}
>>> form = SQLFORM.grid(query, fields=fields, maxtextlength = 100,
>>> deletable = False,
>>> editable = False,
>>> details = False,
>>> create = False,
>>> headers = headers,
>>> selectable = lambda ids: hanteer_verfyning(ids),
>>> orderby = db.akb_authors.auth_id|
>>> db.akb_authors.id)
>>>
>>> the grid use the id's of the akb_articles. Is there an easy way to
>>> convince it to use the id specified in [fields] in stead?
>>>
>>> Regards
>>> Johann
>>> --
>>> Because experiencing your loyal love is better than life itself,
>>> my lips will praise you. (Psalm 63:3)
>>>
>>>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.