Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Using Tap Forms › Ability to color rows in multi-columns?
- This topic has 13 replies, 3 voices, and was last updated 4 years, 5 months ago by Sam Moffatt.
-
AuthorPosts
-
June 11, 2020 at 3:21 AM #40880
pierrot_rennesParticipantHi,
Is it possible to colorize the lines in multicolumn mode according to a check box?
A script?
I have a collection and I would like the row of a record to be colored if the check box is activated for each record
Or even better depending on a value 1 or 2 or 3 in a field, the color would be different
Unless there is another solution?Attachments:
You must be logged in to view attached files.June 11, 2020 at 10:25 PM #40895
Sam MoffattParticipantYou can use a script field to watch another field and set the record colour. Using the TV Shows template, here’s a script to watch a checkbox and set the field to green if checked or white if not:
var completed = record.getFieldValue('fld-25c62d7db6004725910d926d8a7fd085'); if (completed) { record.setRecordColor('#00FF00'); } else { record.setRecordColor('#FFF'); }
Replace the hex colours with your own preferred colours and you can use a similar situation to check if it’s a given number and set the appropriate colouur.
June 12, 2020 at 1:49 AM #40908
pierrot_rennesParticipantHi,
Thank you for the quick reply
I will testJune 12, 2020 at 2:04 AM #40909
pierrot_rennesParticipantTest but error script at line 13
Attachments:
You must be logged in to view attached files.June 12, 2020 at 7:32 AM #40920
Daniel LeuParticipantYou need a closing curly bracket before
Collection()
:function Collection() { var completed = record.getFieldValue('fld-25c62d7db6004725910d926d8a7fd085'); if (completed) { record.setRecordColor('#00FF00'); } else { record.setRecordColor('#FFF'); } } Collection()
June 12, 2020 at 11:00 AM #40924
pierrot_rennesParticipantHi,
Thanks for your help
I made the wrong field in my initial request
I want the line to change color when the check box in the Collection field is activated
I tried to understand and adapt your code with the corresponding field but I have a script execution error (see in join)
If you can help me
Good nightAttachments:
You must be logged in to view attached files.June 12, 2020 at 11:28 AM #40926
Daniel LeuParticipantUse
var collection = ....
and notvar collection_id = ....
June 12, 2020 at 12:09 PM #40927
pierrot_rennesParticipantHi,
I tried but it doesn’t work
At least not as it should
Only the first line is blank (the collection field is not checked)
But the lines with the collection field checked do not change to color (yellow)
What I would like is that all the lines with the collection box activated automatically change color (see in join)
ThanksAttachments:
You must be logged in to view attached files.June 12, 2020 at 2:51 PM #40931
Daniel LeuParticipantWell, it fixes your syntax error, doesn’t it? Sorry, I was only commenting on that and not checking your code!
You should add a
form.saveAllChanges()
at the end of the function to save the color changes.Following script works for me:
function Script() { var check_mark = record.getFieldValue('fld-906aa8b165cf42c0830fd79a460afe75'); if (check_mark) { record.setRecordColor('#f00'); } else { record.setRecordColor('#000'); } form.saveAllChanges(); } Script();
June 12, 2020 at 10:22 PM #40933
Sam MoffattParticipantGood catch on the
form.saveAllChanges()
, should have put that in my original script. Seemed to work ok without it in the small testing I did though.June 13, 2020 at 12:39 AM #40936
pierrot_rennesParticipantHi,
Thank you both very much for your help, it works
It is not automatic when I check the collection box, I have to trigger the script on each recording
(see in join)
Is there a possibility to make this automatic?
good week-endAttachments:
You must be logged in to view attached files.June 13, 2020 at 12:51 AM #40938
Sam MoffattParticipantI think you’ve created a form script rather than a script field. Form scripts are created on the “Scripts” tab but “Field Scripts” are created like normal fields with the type “Script”. Script fields should monitor the state of the fields they reference and auto update when those fields change. Just copy the working form script and put it into a new script field.
June 14, 2020 at 6:15 AM #40950
pierrot_rennesParticipantHi Sam,
It’s done, thanks a lot !!!
If I want to color certain lines in relation to two fields to check, I can put everything in the same script I think?
(with different colors of course ;-))June 14, 2020 at 1:27 PM #40953
Sam MoffattParticipantYeah, use a single script with all of the logic in it, you can pull in as many fields as you like and they’ll all trigger the script. You can then pass it through which ever conditionals you want in the Javascript code to set the row colour.
I would advise against having multiple script fields for setting the row colour because then the logic for the row colour is in two places and debugging that is a nightmare to fix :)
-
AuthorPosts
You must be logged in to reply to this topic.