Is there a way to control the appearance of specific records in table view?
We want certain records to be highlighted or stand out in any other way to simulate multiple records selection.
Cheers,
Maria
Is there a way to control the appearance of specific records in table view?
We want certain records to be highlighted or stand out in any other way to simulate multiple records selection.
Cheers,
Maria
Hi Maria,
maybe setting a background color method can help you out here…
Please look here for more details: http://www.servoyguy.com/code_repository/column_calculations/row_background_color
mboegem:
Hi Maria,maybe setting a background color method can help you out here…
Please look here for more details: http://www.servoyguy.com/code_repository/column_calculations/row_background_color
Well, I’m trying to figure out how rowBGColor can help me in that. However I need to color the rows based on the row index (or the primary key) and every time the user selects another record I need to retain the color of those records that have been selected previously. That means I have to store the selected records in some way, which I do in an array of pks or row indexes. But I can’t really understand how to loop through this array in the calculation.
If anyone can help that would be much appreciated.
Thanks,
Maria
If you have a column that can be used to contain the “is_selected” flag then it can be used in the calculation. If no column, then I found that adding a column like this helps in these situations rather than keep a separate array of selected pks. The adavantage is that the rowbgcalc can then use this column to program the colour of the row. (And yes you have to manage the initialization of the records to the non-selected state before hand).
If you have more than the binary selection required then use another column to calc the “state” or colour of the row bg
For example, I use this technique to colour rows according to the “age” of the record where “age” is calculated to be the number of days exceeding some threshold and I assign a different colour according to the number of days: e.g. 1 to 30 days, 30 to 60 days etc. The “selected row” you should always make some distinguishing colour separate from the other colours.
Ok. I figured that out.
I still don’t exactly understand the mechanism of the calculation but it works.
Besides the calculation uses a form variable - the array that stores the selected records pks. I thought it’s not a good practice to access form vars from a calculation.
Thomas Parry:
If you have a column that can be used to contain the “is_selected” flag then it can be used in the calculation. If no column, then I found that adding a column like this helps in these situations rather than keep a separate array of selected pks. The adavantage is that the rowbgcalc can then use this column to program the colour of the row. (And yes you have to manage the initialization of the records to the non-selected state before hand).If you have more than the binary selection required then use another column to calc the “state” or colour of the row bg
For example, I use this technique to colour rows according to the “age” of the record where “age” is calculated to be the number of days exceeding some threshold and I assign a different colour according to the number of days: e.g. 1 to 30 days, 30 to 60 days etc. The “selected row” you should always make some distinguishing colour separate from the other colours.
Thanks Thomas,
For some reasons we can’t change the table by adding a new column to it.
What does the ‘state’ mean? I mean argument[5] in the list below?
var _rowindex = arguments[0];
var _isSelected = arguments[1];
var _field_type = arguments[2];
var _dataproviderid = arguments[3];
var _form_name = arguments[4];
var _state = arguments[5];
By the way, does anyone know how to find out if the record I click on has already been selected before I clicked on it?
I need it to ‘deselect’ the record if it has been selected.
In the form method onRecordSelection I modify the array of selected records each time a record is selected. If the record is already in the array I remove its index from array; otherwise I add the index. But onRecordSelection does not run when clicking on a record that’s already selected. This is the problem…
maria:
What does the ‘state’ mean? I mean argument[5] in the list below?
_state does return you the whole record that is being evaluated. This way you can test the ‘state’ or ‘value’ of a column.
So let’s say your array that holds pk’s is named ‘selId’, then you could end up returning a hexcolorcode from your calculation when
selId.indexOf(_state.pkId) > -1
maria:
By the way, does anyone know how to find out if the record I click on has already been selected before I clicked on it?
I understand your problem, ran into this a while ago as well.
Seems there’s only one solution: use the onFocus or onAction handler(whichever suits you best in your case) and let this trigger your select/deselect method.
It’s not the nicest - but still the only - way, especially as for example html area’s don’t support the onAction handler. Besides this you’ve to be carefull when you add elements at a later stage to assign the handlers as well…
Maybe this could be a nice feature request as it seems more people seem to struggle with it…
Thanks mboegem,
Yes, this feature would be cool, I’ll lodge the request.
Another question about calculations.
I’m using a form variable in it which is sort of not legitimate for calculations. But it works fine for the moment.
What are the implications of using form variables in calculations?
I’ve been told that - basically - there are no restrictions on what functions or variables to use in calculations. (in fact they are functions itself)
The biggest problem here is that you must be very much aware of the scope you are in when calculations get triggered, as you can end up with a lot of errors when functions or variables can not be used or weren’t initialized at a certain point.
So: leave it, or use it but with error capture on every point a calculation might go wrong!
Maybe a safer solution would be to use global variables and initialize those at startup…
Well, I guess for safety we’d rather show the selected records in a separate window than use the calculation for coloring them.
maria:
Another question about calculations.
I’m using a form variable in it which is sort of not legitimate for calculations. But it works fine for the moment.
What are the implications of using form variables in calculations?
No it is not recommended to use form variables (or anything of a form) in a calculation
Calculations set in the data level they have access to the table data and then a specific record.
a form variable is a ui data thing.
For example that calculation is on a table and you can use that calculation over many forms build on that table
and now that calc is using something of Form X but it is used in Form Z … that can result in funny things.