Highligting Current Record

sure,

the highlighting isn’t triggered by an event script.
In fact in works with an unstored calculation with a specific naming:
“servoy_row_bgcolor”.
If you create a calculation with this name it will automatically starts influencing your row color.

The calculation works on all visible rows in your form:

var recordIndex = arguments[0]; // gets the index of the record
var selected = arguments[1]; //checks if this record is currently selected
if (selected) 
{ 
   return '#CCCCEE'; 
} 
else 
{ 
   if (recordIndex % 2 == 0)//alternate on even oneven 
   { 
      return '#0000FF'; 
   } 
   else 
   { 
      return '#FF0000'; 
   } 
}

Hi! I have just tried the new possibilty and it does work great! Thanks!

There is one issue, though. The function also changes the background color of my controller. So depending on the record you touch, the controller changes its colour everytime. This looks a little odd… Is this fixable?

yes for now don’t base the controller on the same table..
use dummy

I am displaying a found set of a table (for ex: table_A) in a tab panel as list. That tab panel is in a form and that form is linked to the same table_A.

The “servoy_row_bgcolor” effects both the form and list in the tab panel. That’s is correct. But I want the servoy_row_bgcolor to take effect only in the list layout of the tab panel.

I think if we can have arguments[2] that could return the current form name. We can return the background color only if the form name is so and so.

Please advise.

Thanks
Hameed

yes for now don’t base the controller on the same table..
use dummy

that is tricky to do, because I have some controller-driven logic in my controller.

That leads to a question that we have discussed before via mail: does a controller need a dataprovider or wouldn’t it be easier if the controller always refers to the dataprovider of the form that it controls?

I always have a problem to pass information between controller and form that reside on the same dataprovider. Under certain circumstances these two get “out of synch”. I wonder if we could do without these issues if the controller refered always to the data provider of the controlled form.[/quote]

what kind of things do you use in your custom controller so that it has to be based on the same table?

for example a record count (1/20 that sort of thing)…

another issue: since the background color also applies to my controller of course it does the same to my single record view, which is definetly not nice. I think this should only be calculated for forms in list or table view.

We realize the current method is not fine grained enough, in a later version of Servoy we will add the property ‘rowBGColorCalculation’ to a form and a portal, to make it fully adjustable.

Could we also get “servoy_row_fgcolor”??? :lol:

BTW: as for the rowcolor showing on every form based on the table where you add the calculated field: As a work around I added another if-then-else clause int he calculation, in which I evaluate the value of a global, which caries the current formname. If the formname is one of the ones I do not want to use the highlightning for, I just set the color to the normal background color.

Dunno if you could make this work for a controller though. Sadly, the getName function is not available in the calculation area.

Paul

I was wondering: with this option to highlight specific records, is it possible to create something to select multiple records and show that they are selected using this technique?

What I mean is the following:
If you have a list view and you click one of the records, it is highlighted. What I would like is that if I hold down my Control-key and then click on a second record, then both get selected (and so on…).

Now, evaluating the Control key, adding the PK’s of the selected records to an array etc, I can figure it out, but I’m a bit clueless about the possibility of highlighting multiple records, based on the values in an array (or maybe another technique to achieve the same). Is it at all possible?

Any help appreciated…

Paul

you can’t select multiply records at once in a table or listview.

Johan,

I didn’t mean actually selecting multiple records, but sort of faking it… I played around some more and found something that works:

Put this in the Servow_row_BGColor calculation and create a global called “selectedList”, in which you put a string of ID’s that you want to be “selected”.

var recdex = arguments[0];
var test = eval(‘"’+globals.selectedList+‘".indexOf(recdex)’);
if (test == -1)
{
return ‘#ff0000’;
}
else
{
return ‘#3333ff’;
}

Now, you have to fiddle a bit with the proces flow to get it all working neatly, but technically it’s possible.

The only thing is that the string with ID’s in the globals.selectedList has to be properly separated. So, this needs some work. Also, doing something with the result of selected records if you have to get it from the string is a bit more difficult.

Therefor I thought it would be nice if you could store the “selected” ID’s in an array, but then I do not know how to “evaluate” the array in the “Servoy_row_bgcolor” calculation…

So, if anyone has some idea’s on that…

Paul

why not make globals.selectedList an array?
(then type must be media!!)

and then add the id/index to the array.

var array = globals.selectedList;
var found = false;
for(var i=0;i<array.length;i++)
{
if(array == recdex)
{
found = true;
break;
}
}
if(found)
{
// return selected row color
}

I realize the rowBGColor calc seems to be the favored method, but it seems out of step to me to edit the model (by creating a calc) in order to get the view/presentation results you want.

My two cents would be for a way to reference element properties of record x in a foundset.

http://forum.servoy.com/viewtopic.php?t=8789