CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Editable Grid: Update a column value if any other field from that row is updated

Print topic Send  topic

Author Message
pulsorock

Posts: 28
Posted: 10/30/2008, 6:46 AM

Hello,

I created a editable grid, that has 7 fields, 5 of these are editable, the other two are hidden fields. 1 of these hidden fields is the unique id (source_id) of the row and the other is a timestamp field (actualizado). The editable grid shows 4 rows, these rows can only be updated (no new insert or deletes). I need a way to check if for example, any editable field from an specific row was updated or changed.

For example, If any field from row 2 was changed, then the timestamp field from that row get updated too. Otherwise the field does not change.

I have tried using this OnValidateRow event, but havent managed to work. The fields are updated, but the timestamp field does not change.

  
global $DBwapa;  
$partido = $votos_gobernacion->source_id->GetValue;  
  
// Check current values on DB  
$db_votos_aav = CCDLookUp("votos_aav", "wapa_decision2008_gobernacion", "source = '". $partido ."'", $DBwapa);  
$db_votos_eim = CCDLookUp("votos_eim", "wapa_decision2008_gobernacion", "source = '". $partido ."'", $DBwapa);  
$db_votos_lfb = CCDLookUp("votos_lfb", "wapa_decision2008_gobernacion", "source = '". $partido ."'", $DBwapa);  
$db_votos_rfg = CCDLookUp("votos_rfg", "wapa_decision2008_gobernacion", "source = '". $partido ."'", $DBwapa);  
  
// Compare the values with the new ones  
if ($votos_gobernacion->votos_aav->GetValue != $db_votos_aav) {  
$updated = true;  
}  
  
if ($votos_gobernacion->votos_eim->GetValue != $db_votos_eim) {  
$updated = true;  
}  
  
if ($votos_gobernacion->votos_lfb->GetValue != $db_votos_lfb) {  
$updated = true;  
}  
  
if ($votos_gobernacion->votos_rfg->GetValue != $db_votos_rfg) {  
$updated = true;  
}  
  
// If any field was updated, also update the timestamp field  
if ($updated == true) {  
$votos_gobernacion->actualizado->SetValue(date('Y-m-d H:i:s'));  
}  

Any idea? I'm using CCS 3.2.0.4

Thanks
View profile  Send private message
melvyn


Posts: 333
Posted: 10/30/2008, 9:00 AM

GetValue()
  
$partido = $votos_gobernacion->source_id->GetValue();    

There's no parenthesis at the end, so nothing is returned for var $partido, chich is empty, by the way, all CCDlooUp are empty, all if are false and the update to $votos_gobernacion will never run.
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com
View profile  Send private message
pulsorock

Posts: 28
Posted: 10/30/2008, 12:14 PM

Thanks for the comments,

I did the following changes and now works fine.... :)

global $DBwapa;  
$partido = $votos_gobernacion->source_id->GetValue();  
  
// Check current values on DB    
$db_votos_aav = CCDLookUp("votos_aav", "wapa_decision2008_gobernacion", "source = '". $partido ."'", $DBwapa);  
$db_votos_eim = CCDLookUp("votos_eim", "wapa_decision2008_gobernacion", "source = '". $partido ."'", $DBwapa);  
$db_votos_lfb = CCDLookUp("votos_lfb", "wapa_decision2008_gobernacion", "source = '". $partido ."'", $DBwapa);  
$db_votos_rfg = CCDLookUp("votos_rfg", "wapa_decision2008_gobernacion", "source = '". $partido ."'", $DBwapa);  
  
// Compare the values with the new ones    
if ($votos_gobernacion->votos_aav->GetValue() != $db_votos_aav) {  
$updated = true;  
}  
  
if ($votos_gobernacion->votos_eim->GetValue() != $db_votos_eim) {  
$updated = true;  
}  
  
if ($votos_gobernacion->votos_lfb->GetValue() != $db_votos_lfb) {  
$updated = true;  
}  
  
if ($votos_gobernacion->votos_rfg->GetValue() != $db_votos_rfg) {  
$updated = true;  
}  
  
// If any field was updated, also update the timestamp field   
if ($updated == true) {  
$DBwapa->query("UPDATE wapa_decision2008_gobernacion SET actualizado='".date('Y-m-d H:i:s')."' WHERE source='".$partido."'");  
}
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.