如果產品已被選中,我的網格會顯示帶有LEFT OUTER JOIN的產品以顯示額外的信息。Web2py SQLFORM.grid選擇一個字段但不在網格中顯示
所有的作品都很棒。
現在我想將產品說明添加到產品名稱的標題屬性中。因此,當用戶鼠標懸停(鼠標懸停?)名稱時,會顯示說明。
db.product.productname.represent = lambda value, row: A(value, _href=URL('offer', 'view_product', args=row.product.id), _title=row.product.description)
這可以在網格中的字段中包含db.product.description時使用。但是那個列也顯示出來了,我不想要。當我設置.readable = False。該列未顯示,但說明也未顯示。
我也嘗試使用標題只指定我想要顯示的字段,但它仍然顯示說明列。
如何在查詢中包含該字段但不在網格中顯示它?
這裏是整個電網:
pagecontent = SQLFORM.grid(query,
left=db.product_offer_item.on((db.product.id == db.product_offer_item.product_id)\
& (db.product_offer_item.offer_id == currentquote)),
args=[groupid],
create=False,
editable=False,
deletable=False,
details=False,
csv=False,
orderby=db.product.productname,
fields=[db.product.productname,
db.product.purchasecost,
db.product.monthlycost,
db.product_offer_item.optional,
db.product_offer_item.quantity,
db.product_offer_item.discount,
db.product.description # Here is the problem field
],
# headers={'product.productname' : db.product.productname.label,
# 'product.purchasecost' : db.product.purchasecost.label,
# 'product.monthlycost' : db.product.monthlycost.label,
# 'product_offer_item.optional' : db.product_offer_item.optional.label,
# 'product_offer_item.quantity' : db.product_offer_item.quantity.label,
# 'product_offer_item.discount' : db.product_offer_item.discount.label},
maxtextlength = 100,
links=[lambda row: A(T('Update'),
_href='#',
_class='button btn btn-default',
_id=row.product.id,
_name='btnUpdate')
]
)
更新按鈕沒有鏈接,因爲它是由JS處理,以避開不能夠讓每一個排它自己的形式的問題。