rado
Posts: 221
|
| Posted: 11/19/2010, 8:16 PM |
|
Hi,
I would really, really appreciate if somebody can tell me how I can parse the values of the grid row via URL. Now I have grid where the link to another page is dynamic (based on condition, the name of the link is different but in any way it suppose to send 3 same fields (with different values) via URL to another page). I tried to run CCGetFromGet in the "before show" event on target page but couldn't get any values. I also tried to set session variable on page with my grid and tried to retrieve the them on the target page with no luck as well.
I remember that I read on Yes forum something about similar problem where "document.getElementById" should be used, but I don't know how.
For any kind of help thanks a lot.
Rado
|
 |
 |
melvyn
Posts: 333
|
| Posted: 11/19/2010, 9:43 PM |
|
Welcome back again.
You can always get a value from URL using plain PHP:
Let's say your url looks like http://example.com/products.php?make=toyota&color=green
$color = $_GET['color'];
$brand = $_GET['make'];
That's the plain PHP equivalent to CCFromGet()
Since you're working on a grid you need to run the event BeforeShowRow() and take note that $Container (or $Component) isn't the entire grid, only the row.
Le'ts say there's a field named color in each row and you want to modify it In BeforeShowRow event:
$Container->color->SetLabel($_GET['color']); will set that label with the value taken from the URL.
Try it.
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com |
 |
 |
rado
Posts: 221
|
| Posted: 11/19/2010, 9:55 PM |
|
Malvyn,
Before I try it I have to just say big thanks for fast respond.
I will let you know how it goes.
Rado
|
 |
 |
rado
Posts: 221
|
| Posted: 11/19/2010, 10:14 PM |
|
This is what I added in the "Before Show Row" of the grid which has on each row 2 fields ("begin" and "end" -date fields:
$Container->begin->SetLabel($_GET['begin']);
$Container->end->SetLabel($_GET['end']);
In the link property I set parameters "begin" and "end".
Once I added this 2 lines, when I run, I get just blank window. It looks like syntax error that I can't see.
Thanks again Malvyn
|
 |
 |
datadoit
|
| Posted: 11/20/2010, 7:40 AM |
|
There is no SetLabel() function in CCS. It's not a bad assumption to
make, but to make sure that it is indeed a valid function hit the F1 key
and search for it.
To get/set the value of your link control in a grid row, use
GetValue()/SetValue().
To get/set the link of your link control in a grid row, use
GetLink()/SetLink().
To conditionally alter the "value" of a link control, in the grid's
BeforeShowRow or in the link's BeforeShow:
if (this) {
$Container->YourLink->SetValue("Mary had a little lamb");
}
To test for the value of a link control:
if ($Container->YourLink->GetValue() == "Whose teeth were white as snow") {
$Container->YourLink->SetValue("Hickory dickory dock");
}
On a separate note, to deal with the blank screen, turn on error
reporting in your development environment. What you would've seen in
your situation is an error something like "Call to undefined function
SetLabel".
|
|
|
 |
rado
Posts: 221
|
| Posted: 11/20/2010, 8:13 AM |
|
Thanks a lot datadoit,
Let me just explain one more time my case:
I have 2 pages:
1. Page 1 is grid that shows records with dates ("begin" and "end").
On this page I have link ("Lease_term") that should send the date fields via URL (I set in the link parameters "begin" and "end") to Page 2 (RoomReserv2.php).
2. Page 2 is record that have same fields ("begin" and "end").
As a test, I insert the following code in BeforeShowRow of my Page1:
$test_begin = $Container->begin->GetValue();
$Container->Lease_term->SetLink(RoomReserv2.php?begin=$test_begin);
When I run Page 1 I just get blank browser window. When I comment out these 2 lines the Page 1 shows properly.
Thanks again datadoit. This problem is BIG showstopper for my small project and before I resolve it I can't go ahead with the rest of the stuff.
Rado
|
 |
 |
rado
Posts: 221
|
| Posted: 11/20/2010, 8:19 AM |
|
I just fix one mistake which solved "blank screen" problem.
$Container->Lease_term->SetLink("RoomReserv2.php?begin=$test_begin");
when I point my mouse on link I have : http://localhost/kw4rent_intranet/RoomReserv2.php?begin=Array
The field that I parse (begin) is date field. Why I'm getting array. Do I have to format the date filed?
Rado
|
 |
 |
rado
Posts: 221
|
| Posted: 11/20/2010, 8:29 AM |
|
Ohhh, it's progressing (Yeahhhh)
I formatted date and get finally "begin" date populated in Page 2.
But here is additional question:
Since my Page 1 already received the variable via URL, I would like to keep this link and add additional date fields.
Is there any command like "UpdateLink" :)))
Thanks a loooooooooooooooooooooot.
Rado
|
 |
 |
datadoit
|
| Posted: 11/20/2010, 8:46 AM |
|
For your parent grid, when you set your link parameters, did you choose
DataSource Column? Then the parameter source should be the database
field chosen from the dropdown.
You should be able to accomplish what you need with zero custom coding.
See the example:
http://examples.codecharge.com/ExamplePack/NavGrid/NavGrid.php
|
|
|
 |
rado
Posts: 221
|
| Posted: 11/20/2010, 9:22 AM |
|
datadoit and melvyn,
You saved my life. Thanks so much!!!!!
At the and I finished up with 4 lines of code which works perfect. I used the method from example suggested by datadoit.
God bless you
Rado
|
 |
 |