grid for data entry

49 views
Skip to first unread message

T.R.Rajkumar

unread,
Jul 22, 2017, 6:26:48 AM7/22/17
to web2py-users
I want data to be captured for tdr_bid_unrev_detls.rate. I have the query below.

select d.jcod,d.qty,u.rate,u.amt
from tdr_tender_master t join  amc_master m on t.amc_id = m.id
 join amc_details d on m.id = d.amc_id
 left join tdr_bid_unrev_detls u on u.tdr_id = t.id and u.amc_id = m.id
where m.id = 15

This returns the result

jcod         qty      rate    amt
--------------------------------------------
cs001    10.00    NULL    NULL
cs010    10.00    NULL    NULL
cstest    10.00    NULL    NULL
cs002    10.00    NULL    NULL
asd         2.00    NULL    NULL
cs004     5.00     NULL    NULL
test1     10.00     NULL    NULL

Now I would like to fill the rate in the above result in a grid generated by the above query.
I tried this in controller

tdrid = request.vars.tdrid

query = (db.tdr_tender_master.id==tdrid) & (db.tdr_tender_master.amc_id == db.amc_master.id) & (db.amc_master.id == db.amc_details.amc_id) & (db.tdr_bid_unrev_detls.tdr_id == db.tdr_tender_master.id)
left=db.tdr_bid_unrev_detls.on(db.tdr_tender_master.id == db.tdr_bid_unrev_detls.tdr_id)
   
form = SQLFORM.grid(query,left=left)

but i dont get the required form. I want to populate the tdr_bid_unrev_detls table. I am not able to do it myself reading the book. So pl. help. Thanks and regards.

 

T.R.Rajkumar

unread,
Jul 25, 2017, 1:06:25 AM7/25/17
to web2py-users
Any ideas?

Nico de Groot

unread,
Jul 25, 2017, 2:10:04 AM7/25/17
to web2py-users
Looks like you specify the left relation also in the select clause. Debugging tip: you can use _select() to see the SQL generated by the DAL.
To get answers in the forum, it helps if you convert your question to an minimal example using easy to grasp tablenames and relations.

Nico de Groot

Reply all
Reply to author
Forward
0 new messages