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

 Editable Grid submits the empty rows :(

Print topic Send  topic

Author Message
DXBLouie

Posts: 21
Posted: 05/25/2011, 8:39 AM

at first i had the form throw back 4 errors per row, stating each column's value can't be empty.
so i changed the "required" property to No on each text field.. then i realized CCS is actually inserting new rows in the database with "NULL" values for each empty column!

how do i set it up so an editable grid only inserts rows that i actually enter data in, leaving the empty ones out?

i have a hidden field on each row "invoice_id" that's required to link the editable grid data with a master table.
View profile  Send private message
beevet

Posts: 47
Posted: 05/25/2011, 1:36 PM

Do you have a field that has a default value set? Perhaps the default value is 0 or null?

Chris
View profile  Send private message
DXBLouie

Posts: 21
Posted: 05/25/2011, 2:01 PM

well there is a hidden field that gets set on page load, but the rest are all empty..
i'll try to find a way to unset this field on empty rows, or maybe add it in the insert sql instead of the form itself
View profile  Send private message
andy


Posts: 183
Posted: 05/26/2011, 2:19 AM

This may be because at database level you have set default values for fields.
Try
1) removing default values at database level
2) instead use BeforeBuildInsert event to set your default values.
e.g.
  
//BeforeBuildInsert  
  
$container->DataSource->TimeCreated->SetValue(mktime()); // sets current date and time 

I think there is more to it than this, however.
Are you using Editable grid with rows added automatically, or with an Add New button?
_________________
Andy

RAD tools for rich UI controls:
http://www.koolphptools.com
View profile  Send private message
cvboucher

Posts: 191
Posted: 05/26/2011, 8:05 AM

I bet it is the hidden field that is causing code charge to think that row needs to be inserted. In one app I have a page with a record and an editable grid (parent child relationship). In the editable grid I set the Custom Insert Type to Table and for the foreign key field to the parent record I set the parameter type to Expression and the parameter to:

Citation1.GetControl(Of MTHidden)("CitationID").Value

The above line of code references a hidden field in the record. I'm using VB.Net InMotion so I don't know if there is a way to do something similar with the language you are using.

Craig
View profile  Send private message
Oper


Posts: 1195
Posted: 05/26/2011, 8:20 AM

The Logic codecharge use to make the decition when to insert a record on the grid Editable, is when one of the field used any(even hidden) has a value.

to insert and avoid this isue, the Hidden's field should be assigned on the event
BeforeBuildINSERT as andy said

_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
DXBLouie

Posts: 21
Posted: 05/26/2011, 8:43 AM

it's basically an invoice creation form.. two forms, one that creates the invoice header (customer id, date, etc.. and generates the invoice_id), and one that adds the items on the invoice

now when the first form is submitted, it returns to the same page, with invoice_id in the URL.. so the editable grid (for the items) is now displayed, with invoice_id from the URL hidden on each row, so the items can be linked to their invoice.

at the moment i just have it with 3 empty rows, but i'm planning on dynamically adding rows, or maybe put an "add row" button, but i thought i'd tackle this one step at a time :)
View profile  Send private message
cvboucher

Posts: 191
Posted: 05/26/2011, 9:29 AM

Remove the hidden field and set the Custom Insert Type on the editable grid to Table. Then open the Custom Insert properties and add/edit the invoice_id parameter to get the value via the url.

Craig
View profile  Send private message
Oper


Posts: 1195
Posted: 05/26/2011, 9:37 AM

My Adviced personaly dont use CustomInsert if posible.
cuase if you need to change something you will have to remember that especific form has custom insert.


just follow what andy said

1) Keep the Hidden
2) Dont add Default value
3) BeforeBuildInserrt (Assign the Value to that Hidden Field)

Very Simple and anyone even you in the future will understand clear the code
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
DXBLouie

Posts: 21
Posted: 05/26/2011, 9:46 AM

done.. works a treat, thanks guys!

now i need to figure out how to get a modal window with a search form, so while creating an invoice, the user can click an icon on the row, pop the modal window up, search for the product in the popup modal, select the item they like, and that will close the modal and fill the item part number field in the editable grid.

optimistic?
View profile  Send private message
andy


Posts: 183
Posted: 05/27/2011, 1:40 AM

Here are some ideas how you might do that (all untested and off the top of my head :-/)

Rather than making it a popup in which case you would have to save the current record using ajax, why not submit the form to in order to insert/update the record, then conditionally intercept the Redirect to open your lookup form.
Present the lookup form as a report or grid.
In order to select your preferred record (part ?) you can use a checkbox and a form submit button or if you are a little more ambitious click on a record or link field, which submits the form. Either way, you want to submit the form without updating any table (it's only a lookup) BUT you may have to do a fake update if you want to pass the id of your selected record in the URL (you could alternatively use session variables). By a 'fake update' I mean design your update so it doesn't actually update anything but CCS treats it like a meaningful update and therefore uses its default behaviour to pass the part # id in the url (easier).

The lookup form submission then returns the user to the original calling form retaining in the url the original calling record id and now has added to it the selected part id. You can then may be use Before show or BeforeSelect to not only retrieve the original record but also add the part number based on the part number id in the url....

If you use a pop up window then that changes things as you won't be submitting each form. You will have to use AJAX and I would make the pop up modal. When the search window is opened, whatever triggers the opening of this lookup window also acts as a trigger for saving the current record via AJAX (update db). That will ensure that you don't lose anything...

Just some random thoughts that may help...

_________________
Andy

RAD tools for rich UI controls:
http://www.koolphptools.com
View profile  Send private message
DXBLouie

Posts: 21
Posted: 05/27/2011, 5:14 AM

Thanks for the tips Andy,

so far this example almost looks like what i need:
http://examples.codecharge.com/ExamplePack/PopUpList/PopUpList.php
you click the "employees list" link, a popup comes up with a search/grid, and whichever employee name you click, is then passed back to the original form on the main window

that way i can build the form as normal, and submit without having to do fake updates, partial inserts, etc, etc.

i just wish i can do this with an Ajax modal window similar to the password update window here (click 1 or 2 on the user list, then click change password)
View profile  Send private message
andy


Posts: 183
Posted: 05/27/2011, 6:09 AM

Glad you found a solution
_________________
Andy

RAD tools for rich UI controls:
http://www.koolphptools.com
View profile  Send private message
DXBLouie

Posts: 21
Posted: 05/27/2011, 6:38 AM

well not quite.. i'd like to do the same but without an actual popup window.. just an ajax modal :)
View profile  Send private message
datadoit
Posted: 05/27/2011, 7:42 AM

There's also an Ajax modal popup example in the example pack. However,
I personally don't like it, as it requires the modal content to reside
on the same page as the calling page. Thus hosing up fluid layouts.
DXBLouie

Posts: 21
Posted: 05/27/2011, 8:01 AM

i spent a few hours trying to get the popup or the modal to work based on the example.. it's SO frustrating, especially since the examples are incomplete (for instance, it asks you to add javascript to the page from the example.. and that code is only found in the page source, etc)
View profile  Send private message
DXBLouie

Posts: 21
Posted: 06/02/2011, 1:06 PM

i've solved 99% of my issues, albeit with an old-fashioned popup lookup, rather than a modal.

i posted most of it here if anyone is interested
http://forums.yessoftware.com/posts.php?post_id=115780

thanks for the time and help!
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.