Detail Add (+) button visibility issue

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
ebinnasir
User
Posts: 103

Detail Add (+) button visibility issue

Post by ebinnasir »

Hello,

Hope all are fine.

I am working on a master-detail form where a master table is connected with 4 detail table. Detail tables are in tab mode. Add record for detail table is enable along with master-detail add/edit/view. In the master-detail view page a (+) sign is appearing for detail table record add. I want to allow users to add record in detail table only in master-detail add/edit mode and not wanted to allow Individual detail table add record from master-detail view mode. For this i added the below code Row_Rendered and Page_render of List page server events of detail table:

if (CurrentPageID() == "view") {

            $this->OtherOptions["addedit"]->Items["add"]->Visible = false;
        } 

This code hide (+) sign of detail table when in master-detail view mode. Similarly I want to show this (+) sign conditionally in master-detail edit mode. So that below codes put on the Row_Rendered and Page_render of List page server events of detail table:

if (CurrentPageID() == "edit" || $this->isGridEdit()) {

    if (Security()->canEdit()) {

        if (Page("labdip_master")->approval_status->CurrentValue != "Preparing") {
            $this->setFieldProperties("ReadOnly", true);
            $this->OtherOptions["addedit"]->Items["add"]->Visible = false;
        }  
    }
    }

This code show the (+) sign in master-detail edit mode when approval_status == Preparing but error message is showing when approval_status != Preparing. Error message is C:\xampp\htdocs\dye_erp\models\LabdipDetailsGrid.php(2893): Attempt to assign property "Visible" on null.

I tried to hide this button from startup script of Edit Page of Master Table by the below code:

if (approval_status != "Preparing") {
$(".ew-add-blank-row").hide();
$(".ew-grid-upper-panel").hide();
$(".ew-grid-lower-panel").hide();
}

This code also hide the button conditionally but the problem is now (+) sign hide from all detail tables. But I want to hide button from 3 tables and want to show (+) sign in 1 table. Suppose i want to hide (+) button from this tab:
#tab_labdip_details

<div id="flabdip_detailsgrid" class="ew-form ew-list-form">
<div id="gmp_labdip_details" class="card-body ew-grid-middle-panel table-responsive h-auto" style="">
<table id="tbl_labdip_detailsgrid" class="table table-bordered table-hover table-sm ew-table" data-isset="true"><!-- .ew-table -->

Now, My question is there any way to solve the from server side error message Attempt to assign property "Visible" on null.

How to write the appropriate code hide (+) button from startup script for my mentioned tab.

Need suggestion from the experts. Thanks for you help.


arbei
User
Posts: 9384

Post by arbei »

You should check if $this->OtherOptions["addedit"]->Items["add"] is not null first.


ebinnasir
User
Posts: 103

Post by ebinnasir »

Hello,

I don't know how to check Any suggestion or relevant discussion will be appreciated.


arbei
User
Posts: 9384

Post by arbei »

You may use:


ebinnasir
User
Posts: 103

Post by ebinnasir »

What will be the right code format for hiding (+) sign from startup script?

$(".ew-add-blank-row").hide();

This code hides + sign from all tab of that master detail form but i want to hide from particular tab.

Thanks


arbei
User
Posts: 9384

Post by arbei »


Post Reply