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.
Post Reply
vletizia
User
Posts: 4

Problem disabling editing details according to field value

Post by vletizia »

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


sangnandar
User
Posts: 980

Post by sangnandar »

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;
}
}


mobhar
User
Posts: 11660

Post by mobhar »

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


vletizia
User
Posts: 4

Post by vletizia »

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


sangnandar
User
Posts: 980

Post by sangnandar »

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
}


vletizia
User
Posts: 4

Post by vletizia »

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


Post Reply