Problem disabling editing details according to field value

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.

Problem disabling editing details according to field value

Postby vletizia » Fri Dec 29, 2017 2:39 am

Hello everyone,

I'm building an app in PHPMAKER v2017 and I need some help to hide or disable the edit master/detail option in list page as well as disabling the add/edit/delete of the deatil tables when viewing master/detail (multiple tables).

I was able to hide just edit button from the list as well as from the view page doing the follwing:

Server Event->Table-specific->List Page-> ListOptions_Rendered

$CurrentUserRole = $GLOBALS["Security"]->CurrentUserLevelID();
if ($CurrentUserRole == 4){
if ($this->estadoTasacion->CurrentValue == 'XXXXX'){
$this->ListOptions->Items["edit"]->Body="";
//HERE...I need to disable as well edit master/detail
}
}

Then, in Server Event->Table-specific->View Page-> Page Render
$CurrentUserRole = $GLOBALS["Security"]->CurrentUserLevelID();
if ($CurrentUserRole == 4){
if ($this->estadoTasacion->CurrentValue == 'XXXXX'){
$this->OtherOptions["action"]->Items["edit"]->Body = "";
//HERE...I need to disable the posibility of adding/editing/deleting in each detail table
}
}

Any ideas of how I can do that? Should I place the code somewhere else?

Many thanks in advance!

Vero
vletizia
 
Posts: 3
Joined: Fri Sep 29, 2017 11:06 am

Re: Problem disabling editing details according to field val

Postby sangnandar » Fri Dec 29, 2017 4:24 am

vletizia wrote:
> //HERE...I need to disable as well edit master/detail
// for each detail tables
$GLOBALS["detailTableA_grid"]->DetailEdit = FALSE;
$GLOBALS["detailTableB_grid"]->DetailEdit = FALSE;
$GLOBALS["detailTableEtc_grid"]->DetailEdit = FALSE;

This works on ListOptions_Rendered() but I would advice you to move the code to ListOptions_Rendering().
Refer to help file for this event.

vletizia wrote:
> //HERE...I need to disable the posibility of adding/editing/deleting in each detail
> table

// on each detail tables
e.g DetailTableA :
Page_Render() {
if (CurrentPage()->PageID=="view") { //check if master table is in view mode
$this->OtherOptions["addedit"]->Items["add"]->Visible = FALSE;
$this->OtherOptions["addedit"]->Items["edit"]->Visible = FALSE;
$this->ListOptions->Items["delete"]->Visible = FALSE;
}
}
sangnandar
 
Posts: 296
Joined: Mon Sep 19, 2016 2:04 am

Re: Problem disabling editing details according to field val

Postby mobhar » Fri Dec 29, 2017 9:49 am

sangnandar wrote:
> if (CurrentPage()->PageID=="view") { //check if master table is in view mode

// This should be better:
if (CurrentPageID() == "view" && $this->getCurrentMasterTable() != "") { //check if master table is in view mode
mobhar
 
Posts: 4672
Joined: Wed Jun 05, 2013 2:11 pm

Re: Problem disabling editing details according to field val

Postby vletizia » Tue Jan 09, 2018 7:16 am

Hi there!

I tried out your suggestiongs with no luck.

The problem is that if I use Globals I disabled view and editing for the whole grid and I just need to hide the edit and view master/detail link for certain rows. Specifically for the ones that have status with certain values.

I saw the method Row_CustomAction, may I use this?

Thanks in advance
Vero
vletizia
 
Posts: 3
Joined: Fri Sep 29, 2017 11:06 am

Re: Problem disabling editing details according to field val

Postby sangnandar » Tue Jan 09, 2018 3:37 pm

Try this:

Example 1

Disable Master/Detail-Add/Edit/View, e.g. if the detail table name is "orderdetails"

function ListOptions_Rendering() {
$GLOBALS["orderdetails_grid"]->DetailAdd = (...condition...); // Set to TRUE or FALSE conditionally
$GLOBALS["orderdetails_grid"]->DetailEdit = (...condition...); // Set to TRUE or FALSE conditionally
$GLOBALS["orderdetails_grid"]->DetailView = (...condition...); // Set to TRUE or FALSE conditionally
}
sangnandar
 
Posts: 296
Joined: Mon Sep 19, 2016 2:04 am

Re: Problem disabling editing details according to field val

Postby vletizia » Wed Jan 10, 2018 4:56 am

Hi guys!!!

I finally managed to do what I needed in the ListOptions_Rendered() as follows:

function ListOptions_Rendered() {

$CurrentUserRole = $GLOBALS["Security"]->CurrentUserLevelID();

if ($CurrentUserRole == 4){

if ($this->estadoTasacion->CurrentValue == 'STATUS1' || $this->estadoTasacion->CurrentValue == 'STATUS2' ){

$this->ListOptions->Items["edit"]->Body="";
$this->ListOptions->Items["details"]->Visible = FALSE;
}
else{
$this->ListOptions->Items["details"]->Visible = TRUE;
}
}
}

Many thanks for the help and orientation!!!
Vero
vletizia
 
Posts: 3
Joined: Fri Sep 29, 2017 11:06 am


Return to General Discussion (PHPMaker)