[web2py] Re: sqlform.grid add new - populate some fields(with values from another db) based on other fields

2014-06-24 Thread Peter
Thanks. Noted that, thats the best way and might be the only way

On Sunday, 22 June 2014 12:53:51 UTC+3, 黄祥 wrote:

 sorry, didn't read this sentence


 I want these to be reflected even before i click 'submit' button


 if you want to achieve it before click 'submit' button, i think you can 
 achieve it using ajax callback for that.

 best regards,
 stifan 


-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: sqlform.grid add new - populate some fields(with values from another db) based on other fields

2014-06-22 Thread 黄祥


 1. when i select itemcode from dropdown, the form to fill itemname and 
 sellingprice from the stockitems table


i think you can achieve it using form.validate(), use query for stockitems 
table and then insert itemname and sellingprice base on the row of 
stockitems
 

 2. when i enter qty, the amount to be calculated as qty*sellingprice


this one you can do it, either with compute on dal side or you can 
calculate it during form.validate on above method.
e.g. for compute
db.sales.compute = lambda r: r['sellingprice']*r['qty']

ref:
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Computed-fields

another way, i think you can learn much from the web2py appliances 
PosOnlineStore
ref:
https://github.com/mdipierro/web2py-appliances/tree/master/PosOnlineStore
https://github.com/mdipierro/web2py-appliances/tree/master/EStore

best regards,
stifan

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: sqlform.grid add new - populate some fields(with values from another db) based on other fields

2014-06-22 Thread 黄祥
sorry, didn't read this sentence


 I want these to be reflected even before i click 'submit' button


if you want to achieve it before click 'submit' button, i think you can 
achieve it using ajax callback for that.

best regards,
stifan 

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.