Damian Hupfeld
|
| Posted: 02/03/2005, 12:48 PM |
|
I want show/hide 3 grids depending on the results.
members
id
name
level
etc
If the members->level = 1 I want to show grid 1 only.
If the members->level = 2 I want to show grid 2 only.
If the members->level = 3 I want to show grid 3 only.
I thought it might go something like this:
global $grid1;
if ($members->level->GetValue() =="1") $members->Visible = true;
else if ($members->level->GetValue() !="1") $members->Visible =
false;
global $grid2;
if ($members->level->GetValue() =="2") $members->Visible = true;
else if ($members->level->GetValue() !="2") $members->Visible =
false;
global $grid3;
if ($members->level->GetValue() =="3") $members->Visible = true;
else if ($members->level->GetValue() !="3") $members->Visible =
false;
But all my grids are blank.
regards
Damian Hupfeld
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 02/03/2005, 1:59 PM |
|
Damian,
What do you mean by grids being blank? Blank in what way?
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
Damian Hupfeld
|
| Posted: 02/03/2005, 3:15 PM |
|
Sorry PeterR,
None of the 3 grids display.
Basically I have three levels of membership and I want to display more (or
less) information based on their membership level.
I thought maybe create three grids and only display the grid that matches
their membership level?
Damian
"peterr" <peterr@forum.codecharge> wrote in message
news:542029edc67186@news.codecharge.com...
> Damian,
>
> What do you mean by grids being blank? Blank in what way?
> _________________
> Peter R.
> YesSoftware Forums Moderator
> For product support please visit http://support.yessoftware.com
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 02/03/2005, 3:28 PM |
|
Maybe this happens because of circular reference - you're reading value of a grid but at the same time try to hide the grid, so the value may not exist.
Is there a way that you could obtain the member's level from another place, like the database, instead of the grid?
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
peterr
Posts: 5971
|
| Posted: 02/03/2005, 3:30 PM |
|
BTW, which event did you use for this? Before Show of the grid?
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
Damian Hupfeld
|
| Posted: 02/03/2005, 4:07 PM |
|
Before show grid.
I will try reading from the DB or putting a hidden field/grid up first, or
even sending the value in the URL?
"peterr" <peterr@forum.codecharge> wrote in message
news:54202b4035132e@news.codecharge.com...
> BTW, which even did you use for this? Before Show of the grid?
> _________________
> Peter R.
> YesSoftware Forums Moderator
> For product support please visit http://support.yessoftware.com
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
Damian Hupfeld
|
| Posted: 02/03/2005, 4:08 PM |
|
If I do before show row and just hide a row it works, but not if I do before
show grid and try to hide whole grid.
|
|
|
 |
aradi
Posts: 66
|
| Posted: 02/03/2005, 4:30 PM |
|
Hi,
global $grid1;"
if ($members->level->GetValue() =="1") $members->Visible = true;
else if ($members->level->GetValue() !="1") $members->Visible =
false;"
The above code Have "global $grid1" but hides/shows $members grid not $grid1
replace $members->Visible=true to $grid1->visible=true
replace $members->Visible=false to $grid1->visible=false
|
 |
 |
Damian Hupfeld
|
| Posted: 02/03/2005, 4:52 PM |
|
Good spotting - my typo.
I retyped it for the post and obviously mistyped it!
Actual code is correct:
global $directory;
if ($directory->servicelevel->GetValue() =="1") $directory->Visible =
true;
else if ($directory->servicelevel->GetValue() !="1")
$directory->Visible = false;
etc
Oh yeah, that means it doesnt work still 
Damian
|
|
|
 |
Damian Hupfeld
|
| Posted: 02/03/2005, 5:12 PM |
|
The SQL statement would be something like this:
select level from members where id= ????? (this works if I nominate an id eg
id=1029)
How do I get the SQL to pull the record using the id nominated in the url?
eg details.php?id=1029
then <grin> how do I incorporate the SQL query into my php hide/show code?
global $directory;
if ($members->level->GetValue() =="1") $members->Visible = true;
else if ($members->level->GetValue() !="1") $members->Visible =
false;
I obviously need to replace the $members->level->GetValue() with the SQL
code or a variable that has previously run the code...
regards
Damian
Yes I am in over my head!
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 02/04/2005, 12:30 AM |
|
This looks almost exactly the same as the example shown in our tutorial. Take a look at http://docs.codecharge.com/studio/html/QuickStart/Creat...rInitEvent.html
That example also reads some value from the URL, then uses it to lookup another value from the database, then hides the grid based on the results.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
Michael Mikkelsen
|
| Posted: 02/04/2005, 11:55 AM |
|
I like to make a grid at the top of the page that pulls there name and membership level out of the database. I use this grid to display "Welcome -George-" And I use the membership level value from that grid to hide/show other grids in there beforeShow event.
Michael Mikkelsen
|
|
|
 |
Aleko
|
| Posted: 02/24/2005, 12:38 PM |
|
Quote aradi:
Hi,
global $grid1;"
if ($members->level->GetValue() =="1") $members->Visible = true;
else if ($members->level->GetValue() !="1") $members->Visible =
false;"
The above code Have "global $grid1" but hides/shows $members grid not $grid1
replace $members->Visible=true to $grid1->visible=true
replace $members->Visible=false to $grid1->visible=false
http://0cat.com
|
|
|
 |
aradi
Posts: 66
|
| Posted: 02/24/2005, 3:50 PM |
|
Hi,
It looks nice , Can you share your code here?
Best Regards
|
 |
 |