This topic is locked

Hide field if is empty in multi lines list page

3/27/2023 9:46:50 AM
PHPRunner General questions
T
technoserv author

In my project I have put a list page with grid-type advanced 2 columns in which each record is displayed on multiple lines.
I tried setting the "hide if empty" flag but nothing happens.
I tried putting event in in "after record is processed" and also in "before display"
inserting the following code:
if (!$data["date_repl"]){
$pageObject->hideItem("date_repl");
} else {
$pageObject->showItem("date_repl");
}
The result is that the field and its contents are displayed on all rows, even where the condition is applied.
I also tried in "javascript onload event" with the following code:
var ctrldaterepl = Runner.getControl(pageid, 'date_repl');
if(ctrldaterepl.getValue() == ''){
pageObj.hideField("date_repl");
}else{
pageObj.showField("date_repl");}
result field always visible on all lines.
From what I understand it is only a problem on the list page with multi lines grids as they work on a normal list page.
Can anyone help me? Thank you.

T
technoserv author 3/28/2023

Trying and trying, I found the solution.
in before display i hid the label and the field with code
$pageObject->hideItem("grid_id_name", $recordId);
$pageObject->hideField("field_name", $recordId);
It works conditionally, too.
if (!$data["field_name"])
{
$pageObject->hideItem("grid_id_name", $recordId);
$pageObject->hideField("field_name", $recordId);
}