Change background color for HTML field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 11:55 PM
Hello!
I have a custom table which contains an HTML field.
When the field is editable, the field looks like this:
When the field is set to read-only it looks like this:
Is it possible to set the background to gray similar to a text field as seen below:
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2025 04:52 AM
Hi @ceraulo ,
Here is the Solution,
Write a On load Client script on the table,
Use this script
function onLoad() {
var fieldName = 'u_html_1'; // replace with your HTML field's name
var control = g_form.getControl(fieldName);
if (!control) return;
// Wait until the TinyMCE editor is ready
var interval = setInterval(function () {
var editor = tinymce.get(control.id);
if (editor && editor.getDoc && editor.getDoc().body) {
editor.getDoc().body.style.backgroundColor = '#e0e0e0'; // your desired color
clearInterval(interval);
}
}, 500);
}
and that it it works, change the colour accordingly in the code.
tinymce.get() accesses the TinyMCE instance for your HTML field.
editor.getDoc().body.style.backgroundColor directly modifies the iframe body.
A setInterval() waits until TinyMCE fully loads (since it's async).
Mark it as helpful, if it solves your issue.
Thanks,
Rathan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2025 07:16 AM
Thanks for the response!
This works! but only one catch is that it does not load properly when we reload the page multiple times immediately.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2025 07:26 AM
What is the business requirement here? There's no added value in writing scripts that can impact performance to make the field grayed out. This is technical debt and doesn't solve any problem. The field is not editable even if it's not grayed out, so I am not sure what your concern is.
Furthermore, even if you for some reason decide to go with the script that's proposed, which I'd never suggest doing, why would you reload the page multiple times?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2025 10:26 PM
I agree with your perspective that this technical debt isn't necessary since the read-only functionality is already in place.
However, the end user is quite particular about the aesthetics. They find the varying colors for read-only fields on the same page to be inconsistent with the overall user experience.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2025 05:11 AM
you can also try with applying default value to the field