saseow
Posts: 744
|
| Posted: 09/23/2008, 5:53 AM |
|
In a grid with two fields and one label. I want to conditionally set the label value depending on the fields:
Form: category_weights_lu_stat
Field1: list_value
Field2: weight
Label: app_weight
The list_value is either 'Y' or 'N'. If it is 'Y' then the label gets the value of the field 'weight'. If it is no then the label gets the value of 0.
In the Before Show Row event I have custom code:
global$category_weights_lu_stat;
if($category_weights_lu_stat->list_value->GetValue == "Y") {
$category_weights_lu_stat->app_weight->SetValue( $category_weights_lu_stat->weight->GetValue());
}
else
{$category_weights_lu_stat->app_weight->SetValue( $category_weights_lu_stat->weight->GetValue() - $category_weights_lu_stat->weight->GetValue());
}
The label always takes the $category_weights_lu_stat->weight value and does not seem to do the else section.
Something is wrong with mu else coding. Any help would be greatly appreciated!
Thanks!
|
 |
 |
Jack_Walter
Posts: 39
|
| Posted: 09/23/2008, 7:04 AM |
|
Hi,
I'm no programmer but your line
($category_weights_lu_stat->list_value->GetValue == "Y")
looks to me that you are _assigning_ "Y" to the list_value control and by default this condition will always be true...
Regards,
Jack
|
 |
 |
saseow
Posts: 744
|
| Posted: 09/23/2008, 7:30 AM |
|
Thanks Jack,
I would have thought that the SetValue would assign the Y to the list_value, I am going to have to play with this some more I think.
Thanks for your reply.
Trevor
|
 |
 |
mentecky
Posts: 321
|
| Posted: 09/23/2008, 8:14 AM |
|
Trevor,
Try this:
if($category_weights_lu_stat->list_value->GetValue() == "Y")
{
$category_weights_lu_stat->app_weight->SetValue( $category_weights_lu_stat->weight->GetValue());
}
else
{
$category_weights_lu_stat->app_weight->SetValue( $category_weights_lu_stat->weight->GetValue() - $category_weights_lu_stat->weight->GetValue());
}
You are missing the parens on the first GetValue.
Rick
_________________
http://www.ccselite.com |
 |
 |
saseow
Posts: 744
|
| Posted: 09/23/2008, 8:39 AM |
|
Rick, despite your picture, you are a genius! Been searching for hours for the error.
Thank you so much!
Regards,
Trevor
|
 |
 |
mentecky
Posts: 321
|
| Posted: 09/24/2008, 10:29 AM |
|
Trevor,
Don't you hate when that happens? Been there. Sometimes it just takes a second set of eyes. 
No problem. Glad I could help!
Rick
_________________
http://www.ccselite.com |
 |
 |