It would be great to have an alternative to creating a calc field on each table to handle row bg colors (although it is nice that there is at least the calc=]).
e.g. if you wanted to create a global method that did a good job of highlighting the current row you are on by changing the field bgcolor to black and the text to white (on record selection)…
I realize elements are not controlled at the record level, but is there a way to do something like the following for the current selected record?
var current_form_all_elements_array = new Array();
current_form_all_elements_array = forms[currentcontroller.getName()].elements.allnames;
for (var i = 0; i < current_form_all_elements_array.length; i++) {
forms[currentcontroller.getName()].elements[current_form_all_elements_array[i]].transparent=false;
forms[currentcontroller.getName()].elements[current_form_all_elements_array[i]].bgcolor='#000000';
forms[currentcontroller.getName()].elements[current_form_all_elements_array[i]].fgcolor='#ffffff';
}
I guess what I am asking is…is there a way to set properties of an elements for a specific row (in list view e.g.) as opposed to for an entire form all at once? Elements are form objects, so I assume not?
Is it possible to change the properties of an element for a single record in a list view without changing the element properties for the entire form/all records?
this can’t really work in a listview because if you access elements that you change for a listview the whole column. because there is only 1 element set for all the records. And you always just work on the selected record so altering it constantly for every row (in a bgcolor calc) would also not help.
If recoding the calcs is the problem, you could put the color code in a global method and reference it in your calcs.
So, the global method would be… [name=bgCalc]
var index = arguments[0]
var selected = arguments[1]
if(selected)
{
return "#FFFFCC"
}
else
{
if(index % 2 == 0)
{
return "#DCDCDC"
}
else
{
return "#F2F2F2"
}
}
And then you still define a calc for each table, and the code would be …
var index = arguments[0]
var selected = arguments[1]
return globals.bgCalc(index, selected)
Just be very careful with referencing methods inside of calculations. It is okay to do, but make sure your method NEVER touches the GUI. If so, it can possibly trigger other calcs/methods and get into an infinite loop. That is why the methods are omited from list when working in calculations.
I have a same type of problem, but I don’t have the idea that the given solutions in this topic solves my problem.
I have a form in tableview
On my form there are 3 attributes A, B and C
Attribute A must have background color red if it matches a certain condition else it must be orange if it matches another condition and else it must be green.
Attribute B must have default background color
Attribute C must be blue if it matches a certain condition (other condition than conditon for attribute A); otherwise it must be default.
These checks must be done for each record in de tableview. So my form needs to show these backgroundcolors per record.
So the rowBGcolorcalculation is not an option, because it sets background color for the complete record and not for a single attribute.
There are a few workarounds you can use to get the effect you want. In List view you can put a calculation field behind the field in question and colour it using html, based on the value of the field in front, make sure the field in front is transparent.
In Table view you cant really do this, you can make non-editable calcs with differing BG colours however.