Add new button on Master/Detail view page

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

Add new button on Master/Detail view page

Post 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


mobhar
User
Posts: 11660

Post by mobhar »

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

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


ebinnasir
User
Posts: 103

Post 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?


ebinnasir
User
Posts: 103

Post by ebinnasir »

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


ebinnasir
User
Posts: 103

Post 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>";

mobhar
User
Posts: 11660

Post by mobhar »

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


ebinnasir
User
Posts: 103

Post 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.


mobhar
User
Posts: 11660

Post 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.


ebinnasir
User
Posts: 103

Post 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?


mobhar
User
Posts: 11660

Post 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>";

Post Reply