Jain Suvienay
|
| Posted: 04/25/2005, 12:43 AM |
|
Hi,
I am using the same structure as the OrderEntry example in the CCSexample pack.
I have created a new page and used the grid builder to create a grid of records of all the entries in the store_orders_items table so that Ican view all the products ordered in one go.
The main fields in the grid are:
order no., order date, product, quantity, price. (retrieved from orders,order_items tables)
I have added a new field to the grid total to which I have assigned the label totalvalue. in the before show event I have added the following to calculate the value of the totalvalue field
store_orders_items.totalvalue.value = store_orders_items.quantity.value * store_orders_items.price.value
This way the field is automatically populated with the value of the goods.
It is working perfectly fine so far.
However now I want a list of the total value of ALL the orders also.
I tried to use the help file which gave Simple report with total help (refer to help file)
I added new td with field called summ with the show before value calculated as
store_orders_items.summ.value = store_orders_items.summ.value + store_orders_items.totalvalue.value
(as i want the sum total of the totalvalue field for all the orders)
A value is being displayed BUT it contains ONLY the last value of the totalvalue row and not the sum total of all the totalvalue rows
Why is this?
example
quantity
|
|
|
 |
charles
|
| Posted: 04/26/2005, 4:39 AM |
|
Which event are you using to do your calculation?
It has to be the before show row event of the grid and should follow this form
gridname.summ.value =gridname.summ.value + gridname.labelname.value
|
|
|
 |
Jain Suvienay
|
| Posted: 04/26/2005, 7:12 AM |
|
I am using it in the before show row event only!
Still it takes only the last row value in the grid and not all the rows.
format is same:
store_orders_items.summ.value = store_orders_items.summ.value + store_orders_items.totalvalue.value
where store_orders_items is the grid name and totalvalue is the labelname whose sum is required.
Please note that totalvalue is NOT a field in the table but is again dynamically calculated via the same before show event for the label(totalvalue) by assigning its value as a product of quantity(quantity label) and price label.
is this causing the error? and if yes, how do I fix?
|
|
|
 |
Nicole
Posts: 586
|
| Posted: 04/27/2005, 1:08 AM |
|
Jain,
Make sure that sum gets totalvalue after it is calculated, the second point is that sum control should be located outside grid row (i.e. outside <!-- BEGIN Row -->, <!-- END Row --> comments). You can print both sum and totalvalue values from Before Show Row event, it helps you to find where the code fails.
_________________
Regards,
Nicole |
 |
 |
Jain Suvienay
|
| Posted: 04/27/2005, 11:46 PM |
|
Thanks Nicole,
I'll try it out... but can you tell me how to make sure that sum value is calculated afte rtotal value???
Both values before show events occur individually..so by just placing the sum show row after totalvalue show row will solve the problem?
|
|
|
 |
Nicole
Posts: 586
|
| Posted: 04/28/2005, 2:56 AM |
|
Well, in fact I checked example in CCS help and provided my suggestions according to it. You can also refer to this example http://docs.codecharge.com/studio/html/ProgrammingTechn...tWithTotal.html
_________________
Regards,
Nicole |
 |
 |
charles
|
| Posted: 04/28/2005, 9:34 PM |
|
Have tried using the arrow button to adjust the order of excution of your custom code under the before show event?
|
|
|
 |