Tableview Status Point per line

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
}

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.

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.

Hi Matthias,

you can use a calculation or have look at the onRender event.

I still am at the beginning of Servoy, as I can make that as calculation or with the event.
Thank you in advance

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’;
}
}

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. You could try checking if $column is valid:

if($column && $column.your_field<=30){
   // Your code
}

Super many thanks for you.
It functions. :D

Matthias

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:

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:
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

$column['my_field']