CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 editable grid updateallowed problem

Print topic Send  topic

Author Message
donsafar


Posts: 90
Posted: 04/24/2004, 8:24 PM

In the before build update event for an editable grid that display one record per page, I am doing some validation. The validation routine is working and I have the following code:
if ($cnt > 0 )
{
$images_display->UpdateAllowed = false;
$images_display->Errors->addError("Only one Default Picture Allowed per Property");
}

The form submits and the error shows up, the grid item does not display (only field headers) but the record updates when it shouldn't. I have tried the same code in beforebuildupdate and beforeexecuteupdate and both report the error mesage but do not stop the update. This is a custom update, type table. The URL ends up with some of the post info at the end -- PropertyPhotoUpload.php?PropertiesKey=8198&TerritoryID=210&images_displayPage=2&ccsForm=images_display
documentation says this -- UpdateAllowed This is a boolean property whose value determines whether the update operation should proceed or not. The value of this property is set automatically based on the value of the Restricted property of the form. If the Restricted property is set to No, the value of this property is always True unless it is modified using event code in the Before Update event.
Note: There is no "Before Update" event for editable grid.
In debugging, I put this statement in the addError function in classes -- echo "count:".$this->ErrorsCount;
It returned 1. In the Update function I check the errors count after the beforeexecuteupdate and it has 0, so it executes the sql.
If anyone has any ideas on this let me know.


_________________
Don Safar
View profile  Send private message
peterr


Posts: 5971
Posted: 04/24/2004, 8:54 PM

Don,

I think that this should be done in the "On Validate" event, at least based on these two threads:
http://forums.codecharge.com/posts.php?post_id=44975
http://forums.codecharge.com/posts.php?post_id=45411

_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
donsafar


Posts: 90
Posted: 04/25/2004, 10:09 AM

Peter,

The form is an editable grid (only one field or delete). I had tried on validate event. Here is the code:
global $images_display;
global $DBCAPDB;
$def = $images_display->DefaultPicture->GetValue();
echo "def: ".$def. " pid: ".$images_display->PictureID->GetValue()." where: ".$images_display->ds->Where;
exit;
PictureID is a hidden field on the form next to DefaultPicture. The DefaultPicture is a Checkbox (default value of 0). It is checked and then the submit button is clicked. The echo statement returns:
def: 0 pid: where: PropertyID = 8198
It appears control values are not available in onvalidate event which doesn't make sense at all. but in looking at the generated code, it appears to call the onvalidate event, then parses each row and callis an ValidateRow event (which is not listed in the form events as a choice). Here is the ccs generated code.
function Validate()
{
$Validation = true;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidate");

for($RowNumber = 1; $RowNumber <= $this->TotalRows; $RowNumber++)
{
$this->ds->CachedColumns["PictureID"] = $this->CachedColumns["PictureID"][$RowNumber];
$this->DefaultPicture->SetText($this->FormParameters["DefaultPicture"][$RowNumber], $RowNumber);
$this->PictureID->SetText($this->FormParameters["PictureID"][$RowNumber], $RowNumber);
$this->CheckBox_Delete->SetText($this->FormParameters["CheckBox_Delete"][$RowNumber], $RowNumber);

if ($this->UpdatedRows >= $RowNumber) {
if(!$this->CheckBox_Delete->Value)
$Validation = ($this->ValidateRow($RowNumber) && $Validation);
}
else if($this->CheckInsert($RowNumber))
{
$Validation = ($this->ValidateRow($RowNumber) && $Validation);
}
}
return (($this->Errors->Count() == 0) && $Validation);
}
If I move the 2nd line into the for loop, the control values are available and show : def: 1 pid: 187 where: PropertyID = 8198
It also does not update the record then. I do not like to change ccs generated code, but this appears to be a bug or my understanding or which event to use is mistaken. This still has a problem as it leaves this -- &ccsForm=images_display -- at the end of the URL and does not display the photo, it does display the error message. If you have any other ideas let me know, otherwise, I guess I will submit to support. thanks.

_________________
Don Safar
View profile  Send private message
peterr


Posts: 5971
Posted: 04/25/2004, 1:00 PM

I'll have to send this to our engineering to get feedback but please submit to the support at the same time and they'll get back to you that way.
Thanks.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
donsafar


Posts: 90
Posted: 04/26/2004, 9:12 AM

I submitted this to support. I also tried the beforesubmit (no row data available to verify) and aftersubmit (row data available but after row has been updated) events. There seems to be several basic issues. One, the row data is not available to the event (onvalidate, beforesubmit) or Two, the row data is available, the error message is displayed, but the row updates regardless (aftersubmit, beforebuildupdate, beforeexecuteupdate) and this -- &ccsForm=images_display -- is returned at the end of the URL, which I guess is related to form posting, which prevents the current record from displaying in the grid. I'll post here when support responds so others can benefit from the answer.
_________________
Don Safar
View profile  Send private message
donsafar


Posts: 90
Posted: 04/27/2004, 9:16 AM

Per support need to use control onvalidate event. Checkbox does not have this, so have to use hidden control. This appears to partially work. Doesn't update, does display error message, but leaves -- &ccsForm=images_display -- appended to URL which causes grid not to display any records. Per support no way to remove this, Will be addressed in next point release of ccs.:-<
_________________
Don Safar
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.