Page 1 of 1

Displaying HTML in DataGrid (table mode) – supported or not?

Posted: Sun Apr 19, 2026 4:56 pm
by guylouis
Hello,
I’m working with a DataGrid in table mode (not form) in LiveCode.
I would like to display formatted text (HTML), for example something like:
<b>Black</b> <font color="red">Red</font> <b>Black</b>
or more concretely (bridge application):
5 ♥ E+2 where only the ♥ symbol is red.
I have tried several approaches:
set the dgText of group "dgTest" to ...
set the dgData of group "dgTest" to ...
using "htmlText" in the array
setting properties like dgProp["htmlText"] or similar
In all cases, the HTML is either displayed as plain text or ignored.
Question:
Is it actually possible to display HTML-formatted text (with partial colors) inside a DataGrid cell in table mode?
If not:
is there a recommended workaround?
or is switching to a form-style DataGrid / custom template the only solution?
Any clarification on what is officially supported would be very helpful.
Thanks in advance!

Re: Displaying HTML in DataGrid (table mode) – supported or not?

Posted: Sun Apr 19, 2026 6:18 pm
by Emily-Elizabeth
Doesn't look like you can't set the htmlText, perhaps it's something that can be added.

Re: Displaying HTML in DataGrid (table mode) – supported or not?

Posted: Sun Apr 19, 2026 6:54 pm
by richmond62
Doesn't look like you can't set the htmlText, perhaps it's something that can be added.
Looks logically wonky: surely:

"Doesn't look like you can set the htmlText, perhaps it's something that can be added."

Re: Displaying HTML in DataGrid (table mode) – supported or not?

Posted: Mon Apr 20, 2026 4:40 am
by bamakojeff
I do not believe that you can do this in Table mode for a DataGrid. But you can definitely do it in Form mode. Since you put "normal" livecode fields into a form, in your datagrid script to populate the form, you can assign the htmltext of the field just like you can any livecode field.

So if the field in the form was called "bridgeFld", you create an array to hold the data:

Code: Select all

put "5 <font color='#FF0000'>♥</font> E+2" into tDataArray[1]["bid"]
set the dgData of group "myDataGrid" to tDataArray
Then in the script for the datagrid you would write:

Code: Select all

on FillInData pDataArray
   set the htmltext of fld "bridgeFld" of me to pDataArray["bid"]
end FillInData
And your line in the DataGrid would look like
5 E+2
(This assumes that the "foregroundColor" of the field is black. But you could set it to whatever you wanted. Or you could specify all the colors in the HTML text as well if you wished.)

DataGrids are "deep magic" but the basics are not difficult. I've attached a stack which does this if it helps give you ideas.

HTH

Jeff

Re: Displaying HTML in DataGrid (table mode) – supported or not?

Posted: Mon Apr 20, 2026 11:42 am
by guylouis
Thanks Jeff,
That confirms exactly what I was observing.
I initially tried to do this in table mode, but HTML is clearly not supported there (it is either ignored or displayed as plain text). Your explanation about using form mode with real fields makes things much clearer.
In my case (bridge scoring), I specifically wanted to display things like:
5 ♥ E+2 with only the ♥ in red.
I managed to get an acceptable result in table mode using Unicode symbols, but without partial coloring. So for now I’ll probably keep that approach for performance and simplicity.
However, your example with htmlText in a form DataGrid is very helpful, and I may switch to that if I decide to prioritize richer rendering.
Thanks also for the sample stack — much appreciated!
Best regards