Réponse :
1. non, la condition agit pour le champ lui même, quand la condition est vrai
2. oui, on peut mettre autant de conditions que l'on veut, 1 ligne=1 condition
3. oui, "texte" aussi,
Syntaxe
iffieldname1=value1thenbgcolorcolorfontstyleiffieldname1=value2thenbgcolorcolorfontstyleiffieldname2=valuethenbgcolorcolorfontstyle-- Opérators : =, <, >, <>, Contains, NotContain-- numeric value : 1.5 -- string value : "string"
Oui, le cas 1 en plus du comportement original m'intéresse car cela permet d'afficher par exemple un enregistrement en couleur en tenant compte de la valeur d'un seul champs, numérique par exemple. De plus avec la propriété ColumnsWidths il est possible de cacher cette donnée pour n'afficher que les données lisibles par l'usager.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I'm really new to this and still learning about all the functions. I would like to implement a cell color function in a form as well, but on a date field (date format is dd/mm/yyyy) vs today's date. If there are more than 30 days until the cell date = clDefault.
If there are 15 to 30 days left = clYellow
and less than 15 days left = clRed. This is to indicate visually in a list, when an item is due for testing.
I display the list in a form with a DBGrid (DBGrid -->Properties-->Cell ConditionalFormatting)
I got an error message first, without the the color code and font number:
"Error reading DBGrid1.ConditionalFormatting.Strings: DBGrid1 if Retest_Date=<((julianday('now) - (-15d)) then clRed
then exceptet after value"
As I'm loading the data for the DBGrid from a "View", where I gave the date field the Alias "Test Due", it won't recognise the Alias name in ConditionalFormatting. Only if I remove the Alias and leave it as the Field name 'Retest_Date', it tries to work (failing on the date format 'julianday' then). - How can I show an Alias for the column Retest_Date in the DBGrid, if an Alias can't be used in the View filter?
Without analyzing your code, the solution is to make a view, containing 3 columns with your 3 expressions, and thus test the Boolean value in the formatting conditions.
You can then make these columns invisible by specifying the width at 0
sorry to answer you late, I'm on vacation.
The solution is simple, it is a peculiarity of the syntax, it is not necessary to put a comma between the values after the "then"
Hi surfvite, not to worry and enjoy your vacation!
The sample accepts the code, but the color is still not changing. I have also tried changing the colour formatting for the buttons, but to no avail. I'm not sure what the reason could be, maybe I'm missing an important prerequisite I have to set up first? I left some comments in the sql script of the form and the view.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi survite, yes, the colouring on the line works now, thank you. I just have to work on the formula itself, as I'm getting (correctly) the logical result '1' on all entries 15 and 30, if the date is older than 30.
Sorry to keep asking silly questions, you may see it in that file too, in the form 'Service Dates', I tried to color the form [Close] button red (clRed), but changing the color of buttons doesn't seem to be working?
Last edit: Freen 2020-08-23
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I like that we note any anomalies, or questions about NSBase, it allows the software to grow.
I had not seen this setting or the comment in your form
The "Color" property of the buttons does not work natively under windows, but under linux it is correct.
However, I have overloaded this component in version 1.7.1 so that it does not take into account the windows theme when the background color is different from "clDefault"
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I overloaded the component, to display the legend on a colored background when this color is different from clDefault.
To find all the functionalities of this component, in particular the management of glyphs, it is necessary to recatify the windows theme by setting the color to clDefault
Last edit: neuts-jl 2020-08-26
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Bonjour,
met le champs fieldname en couleur chaque fois que sa valeur est plus petite que 2.
Réponse :
1. non, la condition agit pour le champ lui même, quand la condition est vrai
2. oui, on peut mettre autant de conditions que l'on veut, 1 ligne=1 condition
3. oui, "texte" aussi,
Syntaxe
Exemple
Quels sont vos besoins ?
Last edit: neuts-jl 2020-05-04
Je vois pour implémenter le cas 1 et faire évoluer cette fonctionnalité
Oui, le cas 1 en plus du comportement original m'intéresse car cela permet d'afficher par exemple un enregistrement en couleur en tenant compte de la valeur d'un seul champs, numérique par exemple. De plus avec la propriété ColumnsWidths il est possible de cacher cette donnée pour n'afficher que les données lisibles par l'usager.
C'est implementé pour la prochaine version
Last edit: neuts-jl 2020-05-05
Hi, I'm really new to this and still learning about all the functions. I would like to implement a cell color function in a form as well, but on a date field (date format is dd/mm/yyyy) vs today's date. If there are more than 30 days until the cell date = clDefault.
If there are 15 to 30 days left = clYellow
and less than 15 days left = clRed. This is to indicate visually in a list, when an item is due for testing.
I display the list in a form with a DBGrid (DBGrid -->Properties-->Cell ConditionalFormatting)
I got an error message first, without the the color code and font number:
"Error reading DBGrid1.ConditionalFormatting.Strings: DBGrid1 if Retest_Date=<((julianday('now) - (-15d)) then clRed
then exceptet after value"
As I'm loading the data for the DBGrid from a "View", where I gave the date field the Alias "Test Due", it won't recognise the Alias name in ConditionalFormatting. Only if I remove the Alias and leave it as the Field name 'Retest_Date', it tries to work (failing on the date format 'julianday' then). - How can I show an Alias for the column Retest_Date in the DBGrid, if an Alias can't be used in the View filter?
But the following is still utterly wrong >_<;
Any help with this is much appreciated. Thank you.
Hi,
The interpreter used in the datagrid formatting conditions is very rudimentary. It cannot evaluate expressions.
https://sourceforge.net/p/nsbase/forum/howto/thread/55e2c84cb3/#aec1
Without analyzing your code, the solution is to make a view, containing 3 columns with your 3 expressions, and thus test the Boolean value in the formatting conditions.
You can then make these columns invisible by specifying the width at 0
and in conditionnal formating property
Cordially
Last edit: neuts-jl 2020-06-28
Hi surfvite,
Thank you very much for the code above. I didn't know I'm able to add a complete expression into the field, where you pick the table columns.
edit
The date format in the table is dd/mm/YYYY. The following formula worked for me
However, now I need to work out how to "fix" 'cond2', as both, cond1 and cond2 return a value of '1' if the difference is less than 15 days.
Last edit: Freen 2020-06-29
See https://www.techonthenet.com/sqlite/functions/date.php
How can I extract/send the code for one form? I'm fairly sure I've got it all correct now, but the color of the cells in the DBGrid does not change.
The code seems to work, at least I haven't received an error message - Form --> DBGrid --> Properties --> ConditionalFormatting
I believe I have sent you an email/message through the sourceforge site, but I'm not sure if you received it.
No I did not receive anything
I have made a separate sample for the form and attached it here.
sorry to answer you late, I'm on vacation.
The solution is simple, it is a peculiarity of the syntax, it is not necessary to put a comma between the values after the "then"
Hi surfvite, not to worry and enjoy your vacation!
The sample accepts the code, but the color is still not changing. I have also tried changing the colour formatting for the buttons, but to no avail. I'm not sure what the reason could be, maybe I'm missing an important prerequisite I have to set up first? I left some comments in the sql script of the form and the view.
The file is ok
Last edit: neuts-jl 2020-07-22
Have you tried the corrected file ?
Hi survite, yes, the colouring on the line works now, thank you. I just have to work on the formula itself, as I'm getting (correctly) the logical result '1' on all entries 15 and 30, if the date is older than 30.
Sorry to keep asking silly questions, you may see it in that file too, in the form 'Service Dates', I tried to color the form [Close] button red (clRed), but changing the color of buttons doesn't seem to be working?
Last edit: Freen 2020-08-23
Hi,
I like that we note any anomalies, or questions about NSBase, it allows the software to grow.
I had not seen this setting or the comment in your form
The "Color" property of the buttons does not work natively under windows, but under linux it is correct.
However, I have overloaded this component in version 1.7.1 so that it does not take into account the windows theme when the background color is different from "clDefault"
Hi surfvite, got the update, thank you for the quick fix.
Now I have to look where I went wrong with the glyphs, which are not showing in my file (your sample is displaying them fine)... -_-;
Same, glyphs doesn't appear even if the bitmap is loaded
I overloaded the component, to display the legend on a colored background when this color is different from clDefault.
To find all the functionalities of this component, in particular the management of glyphs, it is necessary to recatify the windows theme by setting the color to clDefault
Last edit: neuts-jl 2020-08-26