This topic is locked
[SOLVED]

 Return a value from a function

4/15/2012 6:46:27 PM
PHPRunner General questions
T
Tempus_Erus author

Hi,
I am playing with the listpage.php and wish to insert my own function which will ultimatley determine what 'class' applies to a row - currently set as shade in the CSS file Style.
I have.....
function newcolor()

{
....work out some values here then decide on what 'css code to use'....
$addnewcolor= "class='newshade'"; // to replace .shade CSS

return $addnewcolor; // I want to return this string, tried global not working??
}
Then around line 1800........................
$row = array();

if(!$this->isVerLayout)

{

$row["rowattrs"] = "";

if(! $shade)

{
$this->newcolor(); // call the new color function
$row["rowattrs"] .= $addnewshade; // concantenate the relevent CSS as this loops... $shade = true;

}

else

$shade = false;
The idea here is to set the 'background' of the row to a specific color whilst retaining the mouseover effects.
Currently I am unable to return the value as error reads 'undefined variable'.
Have tried making the sting global but this does not work.
Of course could return a numeric value not just a string, makes little odds really as I can concantenate either..........
Any ideas welcome.............probably a case of can't see the wood for the trees!
Thanks in advance....
Ady

C
cgphp 4/16/2012
T
Tempus_Erus author 4/16/2012

Thanks Cristian,
Aware of these events but you lose the CSS highlight bar. I have approached this before as an "issue" and

was advised cant be done without custom codeing. Ultimatley we add a CSS style to each row. Tested this works fine. Now need to compile programatically so to speak.

C
cgphp 4/19/2012

Can you show me an online demo example of what you want to do?

T
Tempus_Erus author 4/21/2012



Can you show me an online demo example of what you want to do?


Hi Cristian,
Not online at the moment, will a couple of jpgs do?

C
cgphp 4/21/2012

Sure

T
Tempus_Erus author 4/22/2012



Sure


Hi Cristian,
Hopefully this makes sense.
Its a tough ask but definatley 'doable'.
To confrim, the result would be that each row has an assocsiated color according to status, which has

s to be done at this level(?) to retain the highlighting bar as you move the mouse over the list.
We then with the addition of a little jave have an entireley clicakable row.


Thanks in advance
A

C
cgphp 4/22/2012

In the "List page: after record processed" event of the list page, enter the following code:



if(your condition)

$row["rowstyle"]='style="background:red;"';


In the "Javascript onload" event of the list page enter the following code:

$("tr[id^='gridRow']").hover(function(){

$(this).children().addClass('highlight');

},function(){

$(this).children().removeClass('highlight');

});


"highlight" is a css class declared as follows:

<style type="text/css">

.highlight {

background-color: yellow !important;

}

</style>
T
Tempus_Erus author 4/24/2012



In the "List page: after record processed" event of the list page, enter the following code:



if(your condition)

$row["rowstyle"]='style="background:red;"';


In the "Javascript onload" event of the list page enter the following code:

$("tr[id^='gridRow']").hover(function(){

$(this).children().addClass('highlight');

},function(){

$(this).children().removeClass('highlight');

});


"highlight" is a css class declared as follows:

<style type="text/css">

.highlight {

background-color: yellow !important;

}

</style>



Thanks Cristian, I will try later and post feedback.

T
Tempus_Erus author 5/4/2012



Thanks Cristian, I will try later and post feedback.


Cristian,
Thanks,
Works well, too many eggs in my pudding! AGAIN you come up trumps.
A