Home › Forums › Classic DFFS › Field CSS – field background colour
- This topic has 3 replies, 2 voices, and was last updated 4 years, 10 months ago by Alexander Bautz.
-
AuthorPosts
-
-
February 29, 2020 at 16:56 #28943
I can’t find any info regarding the Field CSS options.
I tried applying a background color by
element.style { background-color: blue; }
but that’s clearly not the right way.
I applied this kind of formatting before and I forgot how to do it now 🙁
I have a column called Priority with Priorities 1, 2, 3 and 4. I’d like to apply different colours for each priority. I want this to work in Display Form and Edit Form. This field is Read-Only once it’s set and cannot be changed.
-
February 29, 2020 at 17:10 #28945
Use only the actual CSS styles like this:
background-color: blue;
Alexander
-
February 29, 2020 at 20:00 #28947
Thanks.
How can I apply different colors to different Priorities? Can I do it in Field CSS?
-
-
March 1, 2020 at 11:16 #28949
You can control the background color by for example the status of a choice field – check this example: https://spjsblog.com/forums/topic/dffs-form-examples/#post-19842
This will color the background of the dropdown, but you can change it from the original example:
jQuery("#dffs_Status select").on("change",function(){ var bgColor = "white", txtColor = "black"; switch(jQuery(this).val()){ case "Not started": bgColor = "red"; txtColor = "white"; break; case "In progress": bgColor = "green"; txtColor = "white"; break; case "Completed": bgColor = "gray"; txtColor = "black"; break; } jQuery(this).css({"background-color":bgColor,"color":txtColor}); }).trigger("change");
like this:
jQuery("#dffs_Status select").on("change",function(){ var bgColor = "white", txtColor = "black"; switch(jQuery(this).val()){ case "Not started": bgColor = "red"; txtColor = "white"; break; case "In progress": bgColor = "green"; txtColor = "white"; break; case "Completed": bgColor = "gray"; txtColor = "black"; break; } jQuery(this).parents("tr:first").css({"background-color":bgColor,"color":txtColor}); }).trigger("change");
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.