Page 1 of 1

Text Colour in list View based on logic

Posted: Fri Mar 17, 2017 1:41 pm
by johnberman

Hi

I have a list view that amongst other things has two fields from a table
Durationc
Durations

In the list view if possible I would like to apply some logic like so

If Durationc has no value then display the value of Durations in the nowmal way
If Durationc has a value then display the value of Durations but make the text red

hope this makes sense

Regards
John B


Re: Text Colour in list View based on logic

Posted: Fri Mar 17, 2017 2:53 pm
by mobhar

You may simply use "Row_Rendered" server event. Please read "Server Events and Client Scripts" topic from PHPMaker Help menu for more info and examples.


Re: Text Colour in list View based on logic

Posted: Fri Mar 17, 2017 8:23 pm
by rodrigofaustino2

function Row_Rendered() {
if ($this->Durationc->ViewValue == "") {// List page only
$this->RowAttrs["style"] = "background-color: orange";

	  }else{
		 
		$this->RowAttrs["style"] = "background-color: red";
		
		}

}


Re: Text Colour in list View based on logic

Posted: Fri Mar 17, 2017 11:42 pm
by johnberman

Sorry

Can this be updated so if field durationc has any value at all then field duration has a red background

John B


Re: Text Colour in list View based on logic

Posted: Sat Mar 18, 2017 11:14 pm
by mobhar

Simply change:
$this->RowAttrs["style"] = "background-color: red";

to:
$this->durationc->CellAttrs["style"] = "background-color: red";


Re: Text Colour in list View based on logic

Posted: Sat Mar 18, 2017 11:38 pm
by johnberman

sorry but this works on the first row the condition is met and not on subsequent rows ?

function Row_Rendered() {
if ($this->Durationc->ViewValue == "") {// List page only
$this->RowAttrs["style"] = "background-color: orange";

}else{

$this->Durationc->CellAttrs["style"] = "background-color: red";

}

}

Regards
John B


Re: Text Colour in list View based on logic

Posted: Sat Mar 18, 2017 11:59 pm
by mobhar

Change:
$this->Durationc->ViewValue

to:
$this->Durationc->CurrentValue


Re: Text Colour in list View based on logic

Posted: Sun Mar 19, 2017 12:10 am
by johnberman

Thanks for you never ending patience

John B