Servoy 8 and onRender()

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Servoy 8 and onRender()

Postby wes.s.grayson » Wed Oct 12, 2016 9:08 pm

I recently upgraded from Servoy 7 to Servoy 8.0.3. My application runs fine in developer, but when I upload it to the server and access through the Smart Client, it is painfully slow when switching between records in a table. I finally narrowed this down to being related to the onRender function. Removing the onRender makes everything operate fast again.

I have a form in Table View (locked) with 3 fields, all of which have the following onRender function:

Code: Select all
   
function onRender(event) {
   // TODO Auto-generated method stub
   // NOTE: a property set on the renderable, will be kept on the element only during onRender
   if (event.isRecordSelected()) {
      event.getRenderable().bgcolor = '#0078c1';
      event.getRenderable().fgcolor = '#FFFFFF';
      
   } else if (event.getRecordIndex() % 2) {
      event.getRenderable().bgcolor = '#E6E6E6';   
   }
   

}

This has been working fine for a few years in Servoy 7 and previous versions. Any thoughts?
wes.s.grayson
 
Posts: 43
Joined: Mon Jan 23, 2012 5:39 pm

Re: Servoy 8 and onRender()

Postby goldcougar » Wed Oct 12, 2016 11:19 pm

You should be able to do the same thing with CSS. try removing the onRender, and using this CSS:

Code: Select all
odd, even, selected {
   background-color: #FFFFFF;
   color: #000000;
}
odd {
   background-color: #E6E6E6;
}
selected {
   background-color: #0078c1;
   color: #FFFFFF;
}
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Free Training Videos
Servoy Guy- Free Plugins, Tips & Resources
ServoyForge- Open Source Servoy Components
User avatar
goldcougar
Servoy Expert
 
Posts: 657
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH

Re: Servoy 8 and onRender()

Postby jcompagner » Thu Oct 13, 2016 9:11 am

Which servoy 7 version are we talking about here?

Because the latest servoy 7 or the latest 8 shouldn't be that much difference (if there is a difference at all) for the smartclients with tableview/onrender

Its also very weird that only on the server is affected and not in developer, this can be if there was database access in the onreder method but that doesn't seem to be the case

If you have an example that demonstrates this please make a case.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 7974
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Servoy 8 and onRender()

Postby Gabi Boros » Thu Oct 13, 2016 3:05 pm

can you add an application.output with event.getRecordIndex() so you can track which cells/rows are rendered during record switching ?
is it different if you navigate on the records with keys vs mouse ?
Gabi Boros
Servoy
Gabi Boros
 
Posts: 317
Joined: Tue Jun 26, 2007 4:03 pm
Location: Timisoara, Romania

Re: Servoy 8 and onRender()

Postby wes.s.grayson » Wed Jun 28, 2017 6:59 pm

sorry to bring up an old post but I'm still having the issue. I removed background row coloring and now use CSS for that, which works great. There are still some places where I need to use onRender in Table View to change the color of a field to show a past due date in Red, for example. The onRender function slows down scrolling through records or clicking between. The following onRender function is only set for the one element on my form that needs it.

Code: Select all
var record = event.getRecord()
var dateDue = record.due_date
   if (record)
   {   
      var today = new Date();
      if (dateDue < today)
      {
         event.getRenderable().fgcolor = '#DF0101';
      }
      if (dateDue >= today)
      {
         event.getRenderable().fgcolor = '#111111';
      }
   }


Adding application.output(event.getRecordIndex()) to the function reveals that if I mouse click from row 1 to row 5, I see:
5
1
2
3
4
5

If I use the down arrow from row 1 to 2 I see:
2
1
2

Clicking the scroll button once:
2
3
4
5
6
7
8
9
10
11
12
13
14
15

I'm not sure if these are normal or not. Any other ideas? I'm using 8.0.3.

thanks!
wes.s.grayson
 
Posts: 43
Joined: Mon Jan 23, 2012 5:39 pm

Re: Servoy 8 and onRender()

Postby Gabi Boros » Thu Jun 29, 2017 8:32 am

is it smart or web client ? if it is smart, the call order of onrender may not match the row orders, it dependents when swing wants to paint the component
Gabi Boros
Servoy
Gabi Boros
 
Posts: 317
Joined: Tue Jun 26, 2007 4:03 pm
Location: Timisoara, Romania


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 3 guests

cron