Master/detail separate icon button for view and edit

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

Master/detail separate icon button for view and edit

Post by ebinnasir »

Hi ! everyone,

In the list page there are edit, view, master/detail view & master/detail edit as group button. To hide the single "Edit" and "View" link/button for each record in the main table of List page by putting the following code in "ListOptions_Load" server event:

$this->ListOptions->Items["edit"]->Visible = FALSE;
$this->ListOptions->Items["view"]->Visible = FALSE;
$this->ListOptions->ShowInButtonGroup = FALSE;

This codes hide those two individual edit, view buttons but master/detail view & master/detail edit is still in group as it was. No change happened . I want two separate icon buttons (remove text "master/detail view & master/detail edit") for master/detail view & master/detail edit respectively (same as "Edit" and "View" link/button for each record). If it is not possible then are there any way to rewrite customized link for "Edit" and "View" link/button of each record which i can use same functions like master/detail view & master/detail edit buttons and remove master/detail view & master/detail edit buttons.

Thanks in advance .


mobhar
User
Posts: 11726

Post by mobhar »

You may try ListOptions_Rendering server event.


ebinnasir
User
Posts: 103

Post by ebinnasir »

Below script allow me to create new button and execute custom command like separate button for master/detail edit and master/detail view.

// ListOptions Rendered event
function ListOptions_Rendered()
{
     // create new button for  master/detail edit on list page
  $item = &$this->OtherOptions['action']->Add("NewEdit");
        $item->Body = "<a class='ew-row-link ew-edit' title='nEdit' data-caption='nEdit' href='GrayRequisitionMasterEdit/" . $this->gray_requisition_master_id->CurrentValue . "?showdetail=gray_requisition_details'>nEdit</a>";
        $item->Visible = True;

// create new button for  master/detail view on list page
  $item = &$this->OtherOptions['action']->Add("NewEdit");
        $item->Body = "<a class='ew-row-link ew-edit' title='nView' data-caption='nView' href='GrayRequisitionMasterEdit/" . $this->gray_requisition_master_id->CurrentValue . "?showdetail=gray_requisition_details'>nView</a>";
        $item->Visible = True;
}

Now i am facing two problems:

  1. how to place this two button beside single "Edit" and "View" link/button for each record in the main table of List page?
  2. what is the code that can replace "edit" and "view" text with button icon like "pen" and "magnifying glass"?
  3. $this->ListOptions->Items["details"]->Visible = FALSE; // write this code for hide master/detail edit and master/detail view button but it doesn't work..

Requesting for suggestions from experts. Thanks


mobhar
User
Posts: 11726

Post by mobhar »

When you are using OtherOptions object to create your custom buttons, you should use Page_Render instead of ListOptions_Rendered server event, since ListOptions_Rendered will be executed each time a row of the table is rendered in that Page.

If you want to create your custom buttons next to Edit/View button, then you should use ListOptions instead of OtherOptions object in ListOptions_Rendered server event. You may refer to the generated code in models/YourtableList.php file.


ebinnasir
User
Posts: 103

Post by ebinnasir »

Thanks.

$this->ListOptions->Items["details"]->Visible = FALSE;

write this code for hide master/detail edit and master/detail view button but it doesn't work..

Any suggestions ? Thanks


mobhar
User
Posts: 11726

Post by mobhar »

It should work. I've just tried your code in ListOptions_Rendered server event that belongs to List Page of orders table, and Master/Detail View, Master/Detail Edit, and Master/Detail Copy are hidden completely.


ebinnasir
User
Posts: 103

Post by ebinnasir »

function ListOptions_Rendered()
{
    $this->ListOptions->Items["details"]->Visible = false;
}

But in my case it is not working. showing below error message:

Error
C:\xampp\htdocs\dye_erp\models\GrayRequisitionMasterList.php(2687): Attempt to assign property "Visible" on null

what can i do now?


arbei
User
Posts: 9384

Post by arbei »

ebinnasir wrote:

$this->ListOptions->Items["details"]->Visible = false;

The list option $this->ListOptions->Items["details"] only exists if you have enabled List -> Multiple Detail Tables.


ebinnasir
User
Posts: 103

Post by ebinnasir »

After implementation above suggestions for creating new button next to Edit/View button on each row of table, code looks like below: I want to use this button similar action of "Master/Detail Edit".

$item = &$this->ListOptions['action']->Add("nEdit");
    $item->Body = "<a class='ew-row-link ew-edit' title='nEdit' data-caption='nEdit' href='GrayRequisitionMasterEdit/" . $this->gray_requisition_master_id->CurrentValue . "?showdetail=gray_requisition_details'>nEdit</a>";
    $item->Visible = True;

After generating codes showing below error:
Error
C:\xampp\htdocs\dye_erp\models\GrayRequisitionMasterList.php(2687): Call to a member function Add() on null

Any suggestions which can solve this issue? Thanks


arbei
User
Posts: 9384

Post by arbei »

The error means there is no $this->ListOptions['action']. You may read ListOptions_Load for the available options.


mobhar
User
Posts: 11726

Post by mobhar »

To create additional button on each row next to Edit and View button, then you should use ListOptions_Load and ListOptions_Rendered server events.


ebinnasir
User
Posts: 103

Post by ebinnasir »

Finally it works. What a relief. Thanks for kind suggestion.


shaunroth
User
Posts: 11

Post by shaunroth »

this resolved the issue for me
viewtopic.php?p=188646


Post Reply