kleinmannetje
|
| Posted: 12/14/2004, 2:43 AM |
|
Hello there,
I am implementing the editable grid with 'Add Row' button but I can't figure out how to solve the problem I have.
The problem is that the grid contains hidden field wich contains a value passed from the last page. I have tried to set the value of the hidden field to this value from the URL but then when I submit the form it submits about 30 empty rows in the databse and the row I wanted to add. The grid puts the value in the hidden field of all the 30 rows, even when I only want to add 2 rows or something like that.
Anyone has a solution for this?? I don't know how to solve this.
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 12/14/2004, 3:00 AM |
|
I'm not sure if this will work, but I would probably try something along these lines: kepp your hidden field values empty and do not assign to them any values from the URL until the "Before Insert" and/or "Before Update" events. In other words, assign the URL values only in those two events, instead of "Before Show" or another event that you may be currently using. Those values should not be visible in HTML source of the live page.
You may also need to set your grid's "Preserve Paremeters" property to "GET".
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
kleinmannetje
|
| Posted: 12/14/2004, 3:17 AM |
|
Thanks for your reply
I tried your solution in the Before Submit, Before Build Insert and the Before build update events but it doesn't work. Also I set preserve parameters to "GET". The value isn't stored in the database. I am using the following code to retrieve the variable and set the value of the field, maybe that is the problem:
$suborders->order_id->SetValue(CCGetFromGet("Order_nr", ""));
where
$suborders = grid name
order_id = hidden field
Order_nr = variable passed in URL
Do you know of another solution?
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 12/14/2004, 3:26 AM |
|
Try testing both statements in Before Build Insert:
$suborders->order_id->SetValue(1);
echo CCGetFromGet("Order_nr", "");
Once you know which one doesn't work you could continue onto trying to resolve that specific problem.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
peterr
Posts: 5971
|
| Posted: 12/14/2004, 3:33 AM |
|
Also please try this:
$suborders->ds->cp["order_id"]->SetValue(CCGetFromGet("Order_nr", ""));
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
kleinmannetje
|
| Posted: 12/14/2004, 4:43 AM |
|
I tried the first thing you said. The page printed the Order_nr on the screen but it didn't store the value in the database.
When I try your second solution I get the following error:
Fatal error: Call to a member function on a non-object in C:\Program Files\Apache Group\Apache2\htdocs\farnest\AddSubOrder_events.php on line 115
Line 115 is the line where I put the code.
Do you have another solution or a way to prevent this error??
Thank you for your help so far
|
|
|
 |
Nicole
Posts: 586
|
| Posted: 12/14/2004, 5:25 AM |
|
Hello,
If you do not use Custom Insert and/or Update then assign default values in Before Build Insert and Update events using code
$suborders->ds->order_id->SetValue(CCGetParam("Order_nr", ""));
Or
$suborders->ds->order_id->SetValue(CCGetFromGet("Order_nr", ""));
cp["order_id"] could be used when Custom Insert/Update is built.
_________________
Regards,
Nicole |
 |
 |
kleinmannetje
|
| Posted: 12/14/2004, 5:33 AM |
|
Tanks Nicele!!!
That works like a charm.
|
|
|
 |