Page 1 of 1
Master/detail separate icon button for view and edit
Posted: Wed Apr 12, 2023 9:36 am
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 .
Re: Master/detail separate icon button for view and edit
Posted: Wed Apr 12, 2023 12:35 pm
by mobhar
You may try ListOptions_Rendering server event.
Re: Master/detail separate icon button for view and edit
Posted: Wed Apr 12, 2023 10:53 pm
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:
- how to place this two button beside single "Edit" and "View" link/button for each record in the main table of List page?
- what is the code that can replace "edit" and "view" text with button icon like "pen" and "magnifying glass"?
$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
Re: Master/detail separate icon button for view and edit
Posted: Thu Apr 13, 2023 8:28 am
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.
Re: Master/detail separate icon button for view and edit
Posted: Thu Apr 13, 2023 8:11 pm
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
Re: Master/detail separate icon button for view and edit
Posted: Thu Apr 13, 2023 9:15 pm
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.
Re: Master/detail separate icon button for view and edit
Posted: Thu Apr 13, 2023 10:48 pm
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?
Re: Master/detail separate icon button for view and edit
Posted: Fri Apr 14, 2023 12:27 am
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.
Re: Master/detail separate icon button for view and edit
Posted: Fri Apr 14, 2023 1:56 am
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
Re: Master/detail separate icon button for view and edit
Posted: Fri Apr 14, 2023 8:00 pm
by arbei
The error means there is no $this->ListOptions['action']
. You may read ListOptions_Load for the available options.
Re: Master/detail separate icon button for view and edit
Posted: Sun Apr 16, 2023 12:45 am
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.
Re: Master/detail separate icon button for view and edit
Posted: Sun Apr 16, 2023 10:14 am
by ebinnasir
Finally it works. What a relief. Thanks for kind suggestion.
Re: Master/detail separate icon button for view and edit
Posted: Sun Mar 24, 2024 2:06 am
by shaunroth
this resolved the issue for me
viewtopic.php?p=188646