Page 1 of 1

Add new button on Master/Detail view page

Posted: Fri May 19, 2023 6:12 am
by ebinnasir

Hello,

I am working on a master/detail page. I want to add a button for every row of details record. New button will be locate beside edit/view/delete button of each row. I wrote the below codes;

// ListOptions Load event
function ListOptions_Load()
{
     $item = &$this->ListOptions->add("new");
    $item->Header = "nProduction"; // Set the column header (for List page)
    $item->OnLeft = true; // Link on left
    $item->moveTo(1); // Move the column to the specified index
}


// ListOptions Rendered event
function ListOptions_Rendered()
{
     // create new button on view page of Master/Detail record view page
     $this->ListOptions->Items["nProduction"]->Body = "<a class='ew-row-link ew-detail-edit' title='nProduction' data-caption='nProduction' href='ProductionView/" . $this->gray_requisition_details_id->CurrentValue . "?showdetail='><i data-phrase='fas fa-edit' class = 'icon-edit ew-icon' data-caption='Production Specification'></i></a>";
}

after generating code, i do not see any new button. Can anyone identify where i made mistake. Please help.

Regards
Emran


Re: Add new button on Master/Detail view page

Posted: Fri May 19, 2023 9:00 am
by mobhar

This part:
$this->ListOptions->Items["nProduction"]->Body

should be:
$this->ListOptions->Items["new"]->Body


Re: Add new button on Master/Detail view page

Posted: Fri May 19, 2023 7:36 pm
by ebinnasir

I made the below changes on the detail table listoptions_Rendered server event

$this->ListOptions->Items["new"]->Body

But there are no new button in the master/detail record view page.

I don't want to place new button on the GrayRequisitionMaster list page. New button will be located on the detail data section (gray_requisition_details table) for each row record. Where I have wrote code for new button?


Re: Add new button on Master/Detail view page

Posted: Sat May 20, 2023 8:28 pm
by ebinnasir

I solved the issue. Code need to write in Detail Grid Page of detail table. Thank you all for your suggestions.


Re: Add new button on Master/Detail view page

Posted: Sat May 20, 2023 10:09 pm
by ebinnasir

Can anyone help me to modify the below codes for opening link in the modal window instead of opening browser new window?

// create new button on view page of Master/Detail record view page
     $this->ListOptions->Items["new"]->Body = "<a class='ew-row-link ew-detail-edit' title='nProduction' data-caption='nProduction' href='ProductionView/" . $this->gray_requisition_details_id->CurrentValue . "?showdetail='><i data-phrase='fas fa-edit' class = 'icon-edit ew-icon' data-caption='Production Specification'></i></a>";

Re: Add new button on Master/Detail view page

Posted: Sat May 20, 2023 10:56 pm
by mobhar

You may actually refer to the generated code in the script files that you already setup open the page in Modal dialog.


Re: Add new button on Master/Detail view page

Posted: Sat May 20, 2023 11:09 pm
by ebinnasir

I did not get your point. Sorry for my limited coding knowledge. The above code I write in the newly generated custom button. I want to open production table for view data in modal window/popup window. Now production table data a is opening in the same window now.


Re: Add new button on Master/Detail view page

Posted: Sun May 21, 2023 3:02 pm
by mobhar

What I meant is, you may actually generate the code by yourself, by enabling Modal dialog option for Add, Edit, View, or Search page from Tables setup of your PHPMaker project.

Then you may refer to the generated code of *List.php file inside the generated models sub-folder of your web application.


Re: Add new button on Master/Detail view page

Posted: Mon May 22, 2023 2:25 am
by ebinnasir

Thanks for your suggestion. I checked productionlist.php file and found below codes:

// Add
        $item = &$option->add("add");
        $addcaption = HtmlTitle($Language->phrase("AddLink"));
        if ($this->ModalAdd && !IsMobile()) {
            $item->Body = "<a class=\"ew-add-edit ew-add\" title=\"" . $addcaption . "\" data-table=\"production\" data-caption=\"" . $addcaption . "\" data-ew-action=\"modal\" data-action=\"add\" data-ajax=\"" . ($this->UseAjaxActions ? "true" : "false") . "\" data-url=\"" . HtmlEncode(GetUrl($this->AddUrl)) . "\" data-btn=\"AddBtn\">" . $Language->phrase("AddLink") . "</a>";
        } else {
            $item->Body = "<a class=\"ew-add-edit ew-add\" title=\"" . $addcaption . "\" data-caption=\"" . $addcaption . "\" href=\"" . HtmlEncode(GetUrl($this->AddUrl)) . "\">" . $Language->phrase("AddLink") . "</a>";
        }
        $item->Visible = $this->AddUrl != "" && $Security->canAdd();

From this generated code of productionlist.php file, I tried with the following code for opening production data add form in modal window:

function ListOptions_Rendered()
{
   
    $item = &$this->ListOptions->add("new");
  
    $this->ListOptions->Items["new"]->Body = "<a class='ew-add-edit ew-add' title='nProduction' data-caption='nProduction' data-ew-action='modal' data-action='add' data-ajax=' ' . ($this->UseAjaxActions ? 'true' : 'false')  href='../ProductionAdd". "?showdetail='><i data-phrase='fas fa-edit' class = 'icon-edit ew-icon' data-caption='Production Specification'></i></a>";
}

After generating code, no error message is showing but button is not working. After pressing button nothing is happening.

In my case, I added custom button in grey_details table view page. Custom button will open production table data Add page in modal. Can experts here please help me by giving me working code?


Re: Add new button on Master/Detail view page

Posted: Mon May 22, 2023 9:51 am
by mobhar

You may try:

$this->ListOptions->Items["new"]->Body = "<a class=\"ew-add-edit ew-add\" title=\"nProduction\" data-caption=\"nProduction\" data-ew-action=\"modal\" data-action=\"add\" \"" . ($this->UseAjaxActions ? "true" : "false") . "\"  data-url=\"../ProductionAdd?showdetail=\" data-btn=\"AddBtn\">" . Language()->phrase("AddLink") . "</a>";