This topic is locked
[SOLVED]

 Hide certain Columns for list page

6/23/2011 2:49:31 AM
PHPRunner General questions
jclabuschagne author

PHPR 5.3 build 7474
I have 2 tables: a function table with fields concerning the function details (Venue, Date, Time etc.) then I have a RSVP table which stores every function's attendees' details.
I added extra fields to the function table so the registered user can choose(checkboxes) which fields they want people to fill in. This should then manipulate the SQL query($gSqlHead of the RSVP table) so that certain columns in the RSVP table isn't shown for the particular function.
I want to do this because every function needs different details from the RSVP person.(weddings, corporate etc.)
So the RSVP table has all the fields that any function should require for RSVP purposes, but I need to hide the fields that isn't chosen by the registered user.
I tried the following code in the after table initialized event of the RSVP table, but it didn't work:
NOTE: functions is the master table, and the child table is RSVP.

if($_REQUEST["masterkey1"])

{

$BuildSql="SELECT ";
$sql="SELECT * from functions where FunctionID = ".$_REQUEST["masterkey1"];

$rs = CustomQuery($sql);

$data = db_fetch_array($rs);
if ($data["FieldName"]) //Checks if registered user has ticked the Name field in the functions table

$BuildSql.="Name,"; //If checked, add Name, to the string
if ($data["FieldSurname"])

$BuildSql.="Surname,";
if ($data["FieldGender"])

$BuildSql.="Gender,";
substr($BuildSql,0,-1);//to remove the last "," from the string

}

$gsqlHead=$BuildSql;


Any suggestions to what I'm doing wrong, or do someone know about a suitable workaround? Or does PHPR not support this type of functionality?
I know how to hide the fields on the add, edit and view pages(hidediv), but I also need to hide it on the list page, and this I can't seem to get to work.
Any help would be much appreciated.

C
cgphp 6/23/2011

Johan MMPONLINE,
check this page: http://xlinesoft.com/phprunner/docs/hide_controls_on_add_edit_pages.htm
This is also valid for List page.
Cheers

Cristian

jclabuschagne author 6/24/2011



Johan MMPONLINE,
check this page: http://xlinesoft.com/phprunner/docs/hide_controls_on_add_edit_pages.htm
This is also valid for List page.
Cheers

Cristian


Hallo Cristian,
I added the following code to the before display event of the RSVP table's list page:

if($_REQUEST["masterkey1"])

{

$sql="SELECT * from functions where FunctionID = ".$_REQUEST["masterkey1"];

$rs = CustomQuery($sql);

$data = db_fetch_array($rs);
if ($data["FieldName"]=='')

$xt->assign("Name_fieldblock",false);
if ($data["FieldSurname"]=='')

$xt->assign("Surname_fieldblock",false);
if ($data["FieldGender"]=='')

$xt->assign("Gender_fieldblock",false);

}


This doesn't work, I even stripped my code to the bare minimum to test if the code hides a column:

$xt->assign("Name_fieldblock",false);


Doesn't work. Any suggestions? Or am I a nitwit? <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=59017&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
The field that I tried to hide was "Name", must I use something else instead of "Name_fieldblock" as was the modified syntax from your link above?

C
cgphp 6/24/2011

"fieldblock" is for add and edit pages. The right code:

if($_REQUEST["masterkey1"])

{

$sql="SELECT * from functions where FunctionID = ".$_REQUEST["masterkey1"];

$rs = CustomQuery($sql);

$data = db_fetch_array($rs);
$xt->assign("Name_fieldheadercolumn",$data["FieldName"] != '');

$xt->assign("Name_fieldcolumn",$data["FieldName"] != '');
$xt->assign("Surname_fieldheadercolumn",$data["FieldSurname"] != '');

$xt->assign("Surname_fieldcolumn",$data["FieldSurname"] != '');
$xt->assign("Gender_fieldheadercolumn",$data["FieldGender"] != '');

$xt->assign("Gender_fieldcolumn",$data["FieldGender"] != '');
}
jclabuschagne author 6/24/2011



"fieldblock" is for add and edit pages. The right code:

if($_REQUEST["masterkey1"])

{

$sql="SELECT * from functions where FunctionID = ".$_REQUEST["masterkey1"];

$rs = CustomQuery($sql);

$data = db_fetch_array($rs);
$xt->assign("Name_fieldheadercolumn",$data["FieldName"] != '');

$xt->assign("Name_fieldcolumn",$data["FieldName"] != '');
$xt->assign("Surname_fieldheadercolumn",$data["FieldSurname"] != '');

$xt->assign("Surname_fieldcolumn",$data["FieldSurname"] != '');
$xt->assign("Gender_fieldheadercolumn",$data["FieldGender"] != '');

$xt->assign("Gender_fieldcolumn",$data["FieldGender"] != '');
}



Thanks Cristian!!
You helped me a lot! I just modified your code a bit, but it works!

if ($data["FieldName"] == '0')|| ($data["FieldName"] == '')

{

$xt->assign("Name_fieldheadercolumn",false);

$xt->assign("Name_fieldcolumn",false);

}



if ($data["FieldSurname"] == '0')|| ($data["FieldSurname"] == '')

{

$xt->assign("Surname_fieldheadercolumn",false);

$xt->assign("Surname_fieldcolumn",false);

}

if ($data["FieldGender"] == '0')|| ($data["FieldGender"] == '')

{

$xt->assign("Gender_fieldheadercolumn",false);

$xt->assign("Gender_fieldcolumn",false);

}


I modified it for my coding style, but your's will work also.
Thankyou!
Cheers

Johan