CodeCharge Studio
search Register Login  

Web Reports

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 Insert rows when checkbox is checked (SOLVED)

Print topic Send  topic

Author Message
oceandeep

Posts: 17
Posted: 12/08/2014, 3:16 PM

Hello to everyone,

I'm trying to implement what could be an easy feature in my current app. I wish to be able to choose which rows will be inserted by checking a checkbox control in the same row, in an Editable Grid. I read and followed this post: "http://forums.codecharge.com/posts.php?post_id=122146", but so far it hasn't worked, I've also looked in other posts but they don't seem to be what I need.

Does anyone have an idea on how I can achive that?

CCS 5

Thanks for your help and time.
View profile  Send private message
eratech


Posts: 513
Posted: 12/09/2014, 3:05 AM

oceandeep

Yes, it's do-able. The post you referenced is one I used for updating status flags on records.

You should also look into the 'Before Submit' and 'Before Insert' events ('Before Build Insert' for Editable Grid), as you can check if a value is provided (the checkbox) and set the Editable Grid run-time property 'InsertAllowed' to false so that specific row is not inserted.

Specifically, check the Help Manual for 'InsertAllowed Run-Time Property' and 'Before Submit Event' which mentions 'Checking update rights and Preventing row from updating'

Can you provide a little more detail of what process you are trying to do as that might help (that is, I don't see the point of typing rows into an editable grid then only inserting some ticked ones - why not only enter the ones you want to insert?)

Thanks

Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia
View profile  Send private message
oceandeep

Posts: 17
Posted: 12/09/2014, 6:01 AM

Thank you for your quick response, Eric.

You have given me an idea and I'll try it out today. As for what I'm trying to do, you're right, it sounds illogical in the way I put it but I was in a bit of a hurry so I didn't elaborate. I'm automatically showing in the E.G. data from a table (employees) with some empty cells for aditional info. to be inserted manually. But, that extra info. might not be necesary for all rows. So, I want/need to save only the rows with extra data in another table.

I hope you understand me this time :-)
View profile  Send private message
eratech


Posts: 513
Posted: 12/09/2014, 2:46 PM

Yeah, that sounds like a better use of the EG.

I generally don't use the Insert rows on the EG as I find some of the validation confuses people - they are in 'edit mode' for some records and 'add mode' (in their heads) for others. I usually split them into 2 forms, but that's just what works for my projects.

E
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia
View profile  Send private message
oceandeep

Posts: 17
Posted: 12/09/2014, 2:50 PM

I have a problem. I tried to do what you suggested and at the begining my code wasn't working as I hoped, then I found another post (/posts.php?post_id=117551) with the following code and it worked. I modified it a litlle to make it that if the checkbox is checked then the row shouldn't be inserted:

if ($grid->register->GetValue() == 1) {    
	$grid->DataSource->CmdExecution = false;    
}  

However, that worked when I was testing it in a simple E. grid, meaning, not with the configuration I previously mentioned but just a EG joined to a table where the data will go to and 2 empty rows. When I passed it to my real project and tested it out, all the rows that I don't want to insert show validation errors because of the empty fields. I don't want that, but I can't find a solution that makes CC ignore those rows.

Any ideas?

Thanks.
View profile  Send private message
oceandeep

Posts: 17
Posted: 12/09/2014, 3:13 PM

You know what? Never mind I just realized what the problem was.... I hadn't placed the code in the Before Build Update as it should be according to my grid estructure, and left it in the Before Build Insert instead :-P.

I just changed it and it's working nicely so far :-)
View profile  Send private message
eratech


Posts: 513
Posted: 12/09/2014, 3:52 PM

Excellent - E
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia
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.

PHP Reports

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

Home   |    Search   |    Members   |    Register   |    Login


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