Home > Forum > Data sources > Datasource containing HTML elements

Datasource containing HTML elements
0

Hi community!

In some scenarios it is necessary for us to render datatables on form containing some custom links or buttons.

For this reason we built following SQL statement for testing purposes:

SELECT 'Internal' AS ID,
'<input type="checkbox">Click me</input>' AS HTML
UNION
SELECT 'Azure' AS ID,
'<a href="https://somedomain.com" onclick="alert(''hello'')">Link</a>' AS HTML

And we used this datasource in a datatable field on form.

However, we have some interesting results.

First row is rendered as text (with esacaped html entitities &lt; ...),
the second row is rendered as HTML, also the click event works.

Can someone explain this behaviour?

Is it even possible to add some input elements here?

Thanks in advance & best regards, Nik

MVP

Hello

I've tried to reproduce this behavior, and at version 2022.1.2.59
For the DataTable i'm getting same result as you - Input is rendered as string, and link is rendered properly.

I also tried doing it but with List Items.
When columns were set to text / long text types - it was rendered as string.
It seems like BPS propably due to sanitization uses innerText, and not innerHTML to apply those.

I've also tried using SQL Row attributes, and in both cases i can see that HTML is being rendered, but don't have yet idea how to do it in one column.