onRender background colour of header

Discuss all problems you have with Servoy here. It might help to mention the Servoy version and Operating System version you are using

Re: onRender background colour of header

Postby patrick » Tue Feb 21, 2012 12:13 am

for odd, even and selected you should use a style, not the onRender event. Have a look at the style sample, for example:

selected {
background-color: #3D80DF;
}

odd {
background-color: #f0f0f0;
}

even {
background-color: #FFFFFF;
}
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: onRender background colour of header

Postby john.allen » Tue Feb 21, 2012 4:53 am

What if you want selected rows to have a background color based on some field value in those rows? What is now the best practice? I don't want those fields highlighted but rather the whole background of the row in table view and not based simply on selected, odd or even. Used to be rowBackgroundColor but that is now deprecated and I'm just not sure what is the best practice for achieving the same result. There aren't thousands of rows, maybe a hundred or two hundred at most that might be viewed and those would remain for the whole of the day (so not much dynamic changing of the foundset showing these rows).
John Allen
Stanford University
john.allen
 
Posts: 515
Joined: Wed Jul 02, 2003 10:07 pm
Location: Stanford CA USA

Re: onRender background colour of header

Postby ROCLASI » Tue Feb 21, 2012 9:51 am

Hi John,

For that you would need to use the onRender event.

Hope this helps.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: onRender background colour of header

Postby john.allen » Tue Feb 21, 2012 10:07 am

But does the onRender work well, efficiently with changing the row background color I guess is my question. I seem to remember somewhere that it isn't as efficient as the old rowBackgroundColor. Or am I just imaging stuff again in my old age... Is there a best practices way to do it?
John Allen
Stanford University
john.allen
 
Posts: 515
Joined: Wed Jul 02, 2003 10:07 pm
Location: Stanford CA USA

Re: onRender background colour of header

Postby ROCLASI » Tue Feb 21, 2012 10:56 am

Hi John,

I just conducted some speed tests by doing a foundset.clear() and foundset.loadAllRecords() with and without the onRender event.
I tested on both table view and listview and in all instances the onRender is perhaps 1-2 milliseconds slower than without the onRender event.
All tests were done in Smartclient in Developer 6.0.5.

I used the following testcode:
Code: Select all
foundset.clear();
var _d = new Date();
foundset.loadAllRecords();
application.output(new Date() - _d);


And the following onRender code:
Code: Select all
function onRender(event) {
    if (event.isRecordSelected()) {
        event.getRenderable().bgcolor = '#00ff00';
    } else if (event.getRecordIndex() % 2) {
        event.getRenderable().bgcolor = '#ff0000';
    } else {
        event.getRenderable().bgcolor = '#000000';
    }
}

Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: onRender background colour of header

Postby john.allen » Tue Feb 21, 2012 11:08 am

Thanks Robert! So with those results it would seem to not even make any difference speed-wise at least in using the onRender event for background color of selected, odd and even rows instead of style sheets. (Although onRender did seem to change the label background color in Chris's case who started this thread).
John Allen
Stanford University
john.allen
 
Posts: 515
Joined: Wed Jul 02, 2003 10:07 pm
Location: Stanford CA USA

Re: onRender background colour of header

Postby patrick » Tue Feb 21, 2012 11:12 am

john.allen wrote:(Although onRender did seem to change the label background color in Chris's case who started this thread).


It did not do that in my test...
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: onRender background colour of header

Postby ROCLASI » Tue Feb 21, 2012 12:22 pm

Hi John,

Like Patrick I don't see this either.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: onRender background colour of header

Postby Harjo » Thu Feb 23, 2012 10:47 am

HI John,

you can even combine, the CSS style sheet AND onRender.

do the simple stuff, by CSS, and the more complex stuff by onRender... (btw what you do in onRender, will override the CSS)
It works great!
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: onRender background colour of header

Postby juan.cristobo » Wed Jun 06, 2012 11:05 am

Harjo wrote: (btw what you do in onRender, will override the CSS)


I don't know why, but it doesn't work for me :(

In my CSS I have this:

Code: Select all
odd
{
   background-color: #FFFFFF;
}


And I have this method attached to onRender event of the field:

Code: Select all
function onRender(event)
{
   /**
    * @type {JSRecord<db:/gevs/psi_gevs_reservas_solicitudes>}
    */
   var rec = event.getRecord();
   if(rec) {
      event.getRenderable().bgcolor = '#80ff00';
   }
}


Bgcolor of all rows (odd and even) should be #80ff00, but it's always #FFFFFF in odd rows.
Juan
Madrid (Spain)

Servoy 7.4.x - MySQL / SQL Server 2008-2016
Windows 10 Pro
juan.cristobo
 
Posts: 186
Joined: Thu Apr 19, 2012 9:12 am

Re: onRender background colour of header

Postby Gabi Boros » Wed Jun 20, 2012 9:35 am

as Harjo said, the onRender will override the CSS;
can you check the value of event.getRecord() in your onRender ? is that null ?

juan.cristobo wrote:
Harjo wrote: (btw what you do in onRender, will override the CSS)


I don't know why, but it doesn't work for me :(

In my CSS I have this:

Code: Select all
odd
{
   background-color: #FFFFFF;
}


And I have this method attached to onRender event of the field:

Code: Select all
function onRender(event)
{
   /**
    * @type {JSRecord<db:/gevs/psi_gevs_reservas_solicitudes>}
    */
   var rec = event.getRecord();
   if(rec) {
      event.getRenderable().bgcolor = '#80ff00';
   }
}


Bgcolor of all rows (odd and even) should be #80ff00, but it's always #FFFFFF in odd rows.
Gabi Boros
Servoy
Gabi Boros
 
Posts: 402
Joined: Tue Jun 26, 2007 4:03 pm
Location: Timisoara, Romania

Re: onRender background colour of header

Postby AlanBourke » Tue Jun 30, 2015 1:10 pm

The style sample doesn't have any table views or mention of CSS 'selected' that I can see.
-------------------------------------------------------------------------------------------
Servoy SAN Developer
User avatar
AlanBourke
 
Posts: 198
Joined: Tue Aug 02, 2011 3:32 pm
Location: Dublin, Ireland


Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: No registered users and 2 guests

cron