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 -> General/Other

 Insert Prevention in Editable Grid - A Question

Print topic Send  topic

Author Message
Langston
Posted: 05/28/2004, 2:25 PM

I would like a real expert to confirm a couple of things I find during test:

1. It is too late to set "InsertAllowed" to false in the "Before Build Insert" or "Before Execute Insert" Events for an Editable Grid.

2. You can successfully set "InsertAllowed" to false in the "Before Submit" event but CCS does not provide a mechanism (at least in PHP) whereby you can refer to a control in the current or any specific row.

Are my statements above correct?
Sixto Luis Santos
Posted: 05/28/2004, 3:30 PM

"Langston" <Langston@forum.codecharge> wrote in message
news:240b7ae5cb0c74@news.codecharge.com...
> I would like a real expert to confirm a couple of things I find during
test:
>
> 1. It is too late to set "InsertAllowed" to false in the "Before Build
Insert"
> or "Before Execute Insert" Events for an Editable Grid.

Yes, "BeforeBuildInsert" happens just before preparing the query and sending
it to the DB server but after checking the InsertAllowed property. The
"BeforeInsert" event executes just before checking InsertAllowed though.

>
> 2. You can successfully set "InsertAllowed" to false in the "Before
Submit"
> event but CCS does not provide a mechanism (at least in PHP) whereby you
can
> refer to a control in the current or any specific row.

At that point you could problably refer to a specific control by the
FormParameters property (e.g. $form->FormParameters["control_name"][row] ).
Please note that when "BeforeSubmit" executes, the data has already been
submitted for validation, so there could be no "current" row.

>
> Are my statements above correct?
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
Langston
Posted: 05/28/2004, 5:28 PM

Thanks for your response but I want a clarification on something you wrote:

Yes, "BeforeBuildInsert" happens just before preparing the query and sending
it to the DB server but after checking the InsertAllowed property. The
"BeforeInsert" event executes just before checking InsertAllowed though.

For Editable grids, I believe there is no "BeforeInsert" event but rather "BeforeBuildInsert" and "BeforeExecuteInsert" which BOTH too late to set the "InsertAllow" flag.

peterr


Posts: 5971
Posted: 05/28/2004, 6:12 PM

Hi,

I would have to check with our engineering for details, but I believe that in the new version 2.3 of CCS we improved this by adding special flag "CmdExecution", which you can set to False in the "Before Execute Insert" to prevent insertion of specific records. I just looked at the newly generated 2.3 code for the Editable Grid and it looks like this:
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteInsert");  
        if($this->Errors->Count() == 0 && $this->CmdExecution) {  
            $this->query($this->SQL);  
            $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteInsert");  
        }
(this code is executed once for each grid row being inserted)

We planned to add an example on how to prevent inserting specific rows but I believe that it is not ready yet, as we have several other examples being worked on.
Please refer to this post regarding obtaining CCS 2.3: http://forums.codecharge.com/posts.php?post_id=47459
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Sixto Luis Santos
Posted: 05/28/2004, 6:13 PM

You are right, BeforeInsert only applies to regular forms. In the case of
editable grids, and as you pointed out in your original message, that event
would be BeforeSubmit.
peterr


Posts: 5971
Posted: 05/29/2004, 11:37 AM

Langston,

Back to your original questions:
1. It is too late to set "InsertAllowed" to false in the "Before Build Insert" or "Before Execute Insert".
2. Sorry, I don't understand how setting the "InsertAllowed" is related to referring to row-specific controls.
I believe that "InsertAllowed" can be set to false in page's "After Initialize" event and grid's "Before Submit".
Individual controls can be accessed in "On Validate" event.

BTW, regarding my last solution, there may be several other methods in CCS 2.2. Someone posted previously a solution for ASP that we were not aware of. I've also seen users utilizing clever Where statements.
Therefore it would probably help if you describe your goal because possibly the solution doesn't always need to involve InsertAllowed.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
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.