This topic is locked

Definitive Show/Hide Field Information

3/20/2017 11:13:00 PM
PHPRunner General questions
H
Hertz2P author

Okay, so there's a lot of posts going way back to older versions of phprunner, and I know that some of the methods have changed as more functionality has been built in. I would like to resolve the issue of what exactly is possible as of today.
I know the latest versions have an easy way to hide empty fields on the view page, but not the list page. However if your project is in bootstrap, you can allow the user to hide fields in the list view on the fly, so it stands to reason that you could write code for this.
The reason that I bring all this up is because I've just spent quite a bit of time writing a table that would otherwise have been around 8 tables. I wrote it so that most of the fields are dynamic.. Some appear/disappear dependent on the selection of the first drop-down field. A Lot of the fields that are used have contingent drop-down menus that reflect different choices, also based on the first field.
My code works beautifully on the Add and Edit pages, but not the Inline Add or Edit, and I can't make the empty fields disappear in list view, only in full view.
The reason that this is an issue is because this particular table is a Details table nested into a Master table. As such, I can't Add or View other than Inline in the List view. For some reason, if I Edit a line, and click Add New, a popup opens and my code looks spectacular, but on the add page, it's just a long row of fields that are all visible and it's very hard for anyone to tell which ones they need to put data into.
So, I'll past my code that I've used in the Add and Edit JavaScript Onload events at the bottom, because it's pretty long. What I'm hoping is that someone can tell me how to get it working inside a nested Details Table. I also need a way to make the empty fields disappear in the List page because we never really see the view page for that table.
For the purposes of Add page, it would be acceptable if I could get the popup that I get when I add new from the Edit page. I'm checked the HTML code on both buttons and they're identical, so if someone could explain what causes the two different behaviors, I could run with that.
Right now the Add page only allows for Inline Add. And the list page shows all fields. There is typically only one Detail record in each master as this is a Daily Report form.
I've tried many different ways to try to hide List View fields in the events editor. I'm using the latest build and bootstrap. Here are some of them...
This one apparently works on the view page, but not on the list page.. I tried it on the List page, before display event. It didn't do anything:

if (!$values["EPAHighway"])
$xt->assign("EPAHighway_fieldblock",false);


Then I heard this one was supposed to suppress blank fields on the list page:

if (!$values["YourField"])

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


This one worked, but it also got rid of the Title text for records that were not null and in some cases, didn't display the data.
I read that this one would work if you edited into your html code on the visual editor, but couldn't figure out exactly where to put it, ended up resetting the page about 50 times...

{if $row.1FieldName_value!=""}

<TR><TD class=shade>FieldName</TD>

<TD {$row.1FieldName_style}>{$row.1FieldName_value} </TD></TR>

{/if}


I tried this on the List Page before display event with no luck:

if values("LSFShirtQty")="0" then

pageObject.hideField("LSFStockCode")

pageObject.hideField("LSFDescription")

pageObject.hideField("LSFColour")

pageObject.hideField("LSFCustom")

pageObject.hideField("LSFShirtSize")

pageObject.hideField("LSFShirtQty")

pageObject.hideField("LSFShirtGST")

end if


This one makes the field and data disappear whether it's empty or not:

if (!$values["YourField"])

$pageObject->hideField("YourField");


Anyway, if someone has an easy to follow reference or any solid information on hiding empty fields in List View, Making conditionally visible fields in Inline Add or nested Detail tables, so that I can get my awesome table to work in that environment, I'd love to hear all about it! Here is the code I'm using for the Add & Edit JavaScript Onload Events. It works perfectly for the normal Add & Edit view, just not when the table is nested in a master. I start out by hiding all but the first field and then all the other fields appear/disappear depending on the drop-down selection...

pageObj.hideField("fromMH");

pageObj.hideField("size");

pageObj.hideField("linealFeet");

pageObj.hideField("quantity");

pageObj.hideField("system");

pageObj.hideField("toMH");

pageObj.hideField("toCB");

pageObj.hideField("fromCB");

pageObj.hideField("result");

pageObj.hideField("lotNumbers");

pageObj.hideField("pipeType");

pageObj.hideField("structuresInstalled");

pageObj.hideField("nearestLot");
var ctrlOne = Runner.getControl(pageid, 'type');



ctrlOne.on('change', function(e) {
if (this.getValue() == 'Side Sewer'){

pageObj.showField("pipeType");

pageObj.showField("size");

pageObj.showField("linealFeet");

pageObj.showField("fromMH");

pageObj.showField("toMH");

pageObj.showField("structuresInstalled");

pageObj.showField("quantity");

pageObj.hideField("toCB");

pageObj.hideField("fromCB");

pageObj.hideField("lotNumbers");

pageObj.hideField("nearestLot");

pageObj.hideField("system");

pageObj.hideField("result");
} else if (this.getValue() == 'Sewer') {
pageObj.showField("pipeType");

pageObj.showField("size");

pageObj.showField("linealFeet");

pageObj.showField("fromMH");

pageObj.showField("toMH");

pageObj.showField("structuresInstalled");

pageObj.showField("quantity");

pageObj.hideField("toCB");

pageObj.hideField("fromCB");

pageObj.hideField("lotNumbers");

pageObj.hideField("nearestLot");

pageObj.hideField("system");

pageObj.hideField("result");
} else if (this.getValue() == 'Storm') {
pageObj.showField("pipeType");

pageObj.showField("size");

pageObj.showField("linealFeet");

pageObj.showField("fromCB");

pageObj.showField("toCB");

pageObj.showField("structuresInstalled");

pageObj.showField("quantity");

pageObj.hideField("fromMH");

pageObj.hideField("toMH");

pageObj.hideField("lotNumbers");

pageObj.hideField("nearestLot");

pageObj.hideField("system");

pageObj.hideField("result");
} else if (this.getValue() == 'Lot Drains') {
pageObj.showField("pipeType");

pageObj.showField("size");

pageObj.showField("linealFeet");

pageObj.showField("fromCB");

pageObj.showField("toCB");

pageObj.showField("structuresInstalled");

pageObj.showField("quantity");

pageObj.hideField("fromMH");

pageObj.hideField("toMH");

pageObj.hideField("lotNumbers");

pageObj.hideField("nearestLot");

pageObj.hideField("system");

pageObj.hideField("result");
} else if (this.getValue() == 'Water Main') {
pageObj.showField("pipeType");

pageObj.showField("size");

pageObj.showField("linealFeet");

pageObj.hideField("fromCB");

pageObj.hideField("toCB");

pageObj.hideField("structuresInstalled");

pageObj.hideField("quantity");

pageObj.hideField("fromMH");

pageObj.hideField("toMH");

pageObj.hideField("lotNumbers");

pageObj.hideField("nearestLot");

pageObj.hideField("system");

pageObj.hideField("result");
} else if (this.getValue() == 'Service') {
pageObj.showField("pipeType");

pageObj.showField("lotNumbers");

pageObj.hideField("size");

pageObj.hideField("linealFeet");

pageObj.hideField("fromCB");

pageObj.hideField("toCB");

pageObj.hideField("structuresInstalled");

pageObj.hideField("quantity");

pageObj.hideField("fromMH");

pageObj.hideField("toMH");

pageObj.hideField("nearestLot");

pageObj.hideField("system");

pageObj.hideField("result");
} else if (this.getValue() == 'Water Cut Downs') {
pageObj.showField("pipeType");

pageObj.showField("lotNumbers");

pageObj.hideField("size");

pageObj.hideField("linealFeet");

pageObj.hideField("fromCB");

pageObj.hideField("toCB");

pageObj.hideField("structuresInstalled");

pageObj.hideField("quantity");

pageObj.hideField("fromMH");

pageObj.hideField("toMH");

pageObj.hideField("nearestLot");

pageObj.hideField("system");

pageObj.hideField("result");
} else if (this.getValue() == 'Air Vac') {
pageObj.showField("nearestLot");

pageObj.hideField("lotNumbers");

pageObj.hideField("size");

pageObj.hideField("linealFeet");

pageObj.hideField("fromCB");

pageObj.hideField("toCB");

pageObj.hideField("structuresInstalled");

pageObj.hideField("quantity");

pageObj.hideField("fromMH");

pageObj.hideField("toMH");

pageObj.hideField("pipeType");

pageObj.hideField("system");

pageObj.hideField("result");
} else if (this.getValue() == 'Blow Off') {
pageObj.showField("nearestLot");

pageObj.hideField("lotNumbers");

pageObj.hideField("size");

pageObj.hideField("linealFeet");

pageObj.hideField("fromCB");

pageObj.hideField("toCB");

pageObj.hideField("structuresInstalled");

pageObj.hideField("quantity");

pageObj.hideField("fromMH");

pageObj.hideField("toMH");

pageObj.hideField("pipeType");

pageObj.hideField("system");

pageObj.hideField("result");
} else if (this.getValue() == 'Hydrant Install') {
pageObj.showField("quantity");

pageObj.showField("nearestLot");

pageObj.hideField("lotNumbers");

pageObj.hideField("size");

pageObj.hideField("linealFeet");

pageObj.hideField("fromCB");

pageObj.hideField("toCB");

pageObj.hideField("structuresInstalled");

pageObj.hideField("fromMH");

pageObj.hideField("toMH");

pageObj.hideField("pipeType");

pageObj.hideField("system");

pageObj.hideField("result");
} else if (this.getValue() == 'Level Spreaders') {
pageObj.showField("linealFeet");

pageObj.showField("nearestLot");

pageObj.hideField("lotNumbers");

pageObj.hideField("size");

pageObj.hideField("fromCB");

pageObj.hideField("toCB");

pageObj.hideField("structuresInstalled");

pageObj.hideField("quantity");

pageObj.hideField("fromMH");

pageObj.hideField("toMH");

pageObj.hideField("pipeType");

pageObj.hideField("system");

pageObj.hideField("result");
} else if (this.getValue() == 'Test/TV') {
pageObj.showField("system");

pageObj.showField("result");

pageObj.hideField("nearestLot");

pageObj.hideField("lotNumbers");

pageObj.hideField("size");

pageObj.hideField("linealFeet");

pageObj.hideField("fromCB");

pageObj.hideField("toCB");

pageObj.hideField("structuresInstalled");

pageObj.hideField("quantity");

pageObj.hideField("fromMH");

pageObj.hideField("toMH");

pageObj.hideField("pipeType");
} else if (this.getValue() == 'Clean Flush') {
pageObj.showField("system");

pageObj.hideField("nearestLot");

pageObj.hideField("lotNumbers");

pageObj.hideField("size");

pageObj.hideField("linealFeet");

pageObj.hideField("fromCB");

pageObj.hideField("toCB");

pageObj.hideField("structuresInstalled");

pageObj.hideField("quantity");

pageObj.hideField("fromMH");

pageObj.hideField("toMH");

pageObj.hideField("pipeType");

pageObj.hideField("result");
} else {
pageObj.hideField("fromMH");

pageObj.hideField("size");

pageObj.hideField("linealFeet");

pageObj.hideField("quantity");

pageObj.hideField("system");

pageObj.hideField("toMH");

pageObj.hideField("toCB");

pageObj.hideField("fromCB");

pageObj.hideField("result");

pageObj.hideField("lotNumbers");

pageObj.hideField("pipeType");

pageObj.hideField("structuresInstalled");

pageObj.hideField("nearestLot");

}

});
// Place event code here.

// Use "Add Action" button to add code snippets.