Tableview Status Point per line

Questions, tips and tricks and techniques for scripting in Servoy

Tableview Status Point per line

Postby matthias_suck » Sat Sep 10, 2011 11:31 am

Hello Forum,

I would like to let a status indicate in a Tableview at the end of each line as red ones, yellow one, the Green point.
Depending on are all red or green or yellow

My Code:
var tt_ndl = forms.Next_Due_List.controller.getMaxRecordIndex()
for ( i = 0 ; i <= tt_ndl ; i++) {
if (forms.Next_Due_List.warning <= 0 & forms.Next_Due_List.ub == 0){
forms.Next_Due_List.elements.AP1.bgcolor = "Red"
forms.Next_Due_List.elements.AP1.transparent= false
}
if ((forms.Next_Due_List.warning > 0 & forms.Next_Due_List.warning < 30) & forms.Next_Due_List.ub == 0){
forms.Next_Due_List.elements.AP1.bgcolor = "Yellow"
forms.Next_Due_List.elements.AP1.transparent= false
}
if (forms.Next_Due_List.warning >= 30 & forms.Next_Due_List.ub == 0){
forms.Next_Due_List.elements.AP1.bgcolor = "Lime"
forms.Next_Due_List.elements.AP1.transparent= false
}

forms.Next_Due_List.controller.setSelectedIndex(1)
return true
}
Attachments
Tableview.PNG
Tableview.PNG (47.6 KiB) Viewed 6923 times
matthias_suck
 
Posts: 10
Joined: Wed Mar 09, 2011 11:17 am

Re: Tableview Status Point per line

Postby patrick » Sat Sep 10, 2011 11:49 am

Could you try again to explain under which circumstances you want the color to be red, yellow or green? Somehow I didn't get it.
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Tableview Status Point per line

Postby matthias_suck » Sat Sep 10, 2011 12:05 pm

If in the column " Rest" the value <= 0 is should the point red be and if the value between > 0 and 30 equal yellow its and if the value >= 30 is should it green be. If in the column " Header" 1 (Filed "ub") then it should be transparency.
matthias_suck
 
Posts: 10
Joined: Wed Mar 09, 2011 11:17 am

Re: Tableview Status Point per line

Postby Peter de Groot » Sat Sep 10, 2011 12:36 pm

Hi Matthias,

you can use a calculation or have look at the onRender event.
User avatar
Peter de Groot
 
Posts: 215
Joined: Thu Jan 10, 2008 8:38 pm
Location: Not sure...

Re: Tableview Status Point per line

Postby matthias_suck » Sat Sep 10, 2011 1:00 pm

I still am at the beginning of Servoy, as I can make that as calculation or with the event.
Thank you in advance
matthias_suck
 
Posts: 10
Joined: Wed Mar 09, 2011 11:17 am

Re: Tableview Status Point per line

Postby Peter de Groot » Sat Sep 10, 2011 1:14 pm

you could do something like for the column you want to color

function onRender(event) {
var $source;

$source = event.getRenderable();
/** @type JSRecord<db:/database/table name> */
var $column = event.getRecord();

if($column.your_field <= 30){
$source.bgcolor = '#FFA500';
}
}
User avatar
Peter de Groot
 
Posts: 215
Joined: Thu Jan 10, 2008 8:38 pm
Location: Not sure...

Re: Tableview Status Point per line

Postby matthias_suck » Sat Sep 10, 2011 2:09 pm

I get the following error:
TypeError: Cannot read property "warning" from (C:\Users\matthias\servoy_workspace\FMS\forms\Next_Due_List.js#24)
at C:\Users\matthias\servoy_workspace\FMS\forms\Next_Due_List.js:24 (onRender)
matthias_suck
 
Posts: 10
Joined: Wed Mar 09, 2011 11:17 am

Re: Tableview Status Point per line

Postby jasantana » Mon Sep 12, 2011 10:09 am

Matthias. You could try checking if $column is valid:

Code: Select all
if($column && $column.your_field<=30){
   // Your code
}
Best regards,
Juan Antonio Santana Medina
jasantana@nephos-solutions.co.uk
Servoy MVP 2015
Servoy 6.x - Servoy 7.x - Servoy 8.x - MySQL - PostgreSQL - Visual Foxpro 9
User avatar
jasantana
 
Posts: 555
Joined: Tue Aug 10, 2010 11:40 am
Location: Leeds - West Yorkshire - United Kingdom

Re: Tableview Status Point per line

Postby matthias_suck » Mon Sep 12, 2011 11:59 am

Super many thanks for you.
It functions. :D

Matthias
matthias_suck
 
Posts: 10
Joined: Wed Mar 09, 2011 11:17 am

Re: Tableview Status Point per line

Postby tizzo » Mon Sep 12, 2011 4:07 pm

I understand that the following code:
/** @type JSRecord<db:/database/table name> */
var $column = event.getRecord();

lets get variable $column access to table' s field... how could I use the same technique when I have a runtime-created datasource?

I can make an output of the data in the records, for example:
Code: Select all
Record[DATA:Row(mem:_gDataSourceGiornList)[DATA:_sv_rowid=279,idgiornaliera=3.1826992E7,giornomese=31,nomegiorno=LU,evento_1=L.D. 8.00,evento_2=null,evento_3=S   1.00,evento_4=null,evento_5=null,evento_6=null,evento_7=null,  CALCULATIONS: {}]]  COLUMS: _sv_rowid,idgiornaliera,giornomese,nomegiorno,evento_1,evento_2,evento_3,evento_4,evento_5,evento_6,evento_7,rollbackChanges,getDataSource,save,getPKs,setFoundset,deleteRecord,getChangedData,setException,getFoundset,getException,isEditing,...


but I can't get the value, as record.giornomese returns always null
tizzo
 
Posts: 10
Joined: Tue Apr 19, 2011 5:35 pm

Re: Tableview Status Point per line

Postby jasantana » Mon Sep 12, 2011 6:49 pm

tizzo wrote:lets get variable $column access to table' s field... how could I use the same technique when I have a runtime-created datasource?


You could try by using
Code: Select all
$column['my_field']
Best regards,
Juan Antonio Santana Medina
jasantana@nephos-solutions.co.uk
Servoy MVP 2015
Servoy 6.x - Servoy 7.x - Servoy 8.x - MySQL - PostgreSQL - Visual Foxpro 9
User avatar
jasantana
 
Posts: 555
Joined: Tue Aug 10, 2010 11:40 am
Location: Leeds - West Yorkshire - United Kingdom


Return to Methods

Who is online

Users browsing this forum: No registered users and 5 guests

cron