How can I display indented, i.e. prettified XML in a DataGrid column?
Hi @Blaze,
You can try combining the approach from here: https://stackoverflow.com/questions/1123718/format-xml-string-to-print-friendly-xml-string with a <pre>
element used in the Template of a column:
<Template>
<pre>
@PrintXML(context.XmlProperty)
</pre>
</Template>
Or if using Radzen set the Template property of the column to:
<pre>${PrintXML(data.XmlProperty)}</pre>
Add the PrintXML method to the partial class of your page (xxx.razor.cs)
That works but now it is centered by default so I added "TextAlign="TextAlign.Left"" to the column but it has no effect. It also has no effect on other columns.
Please share the code snippet here
Check the alignment by inspecting the <pre>
with your Browser's developer tools. By the default all text is left aligned so it is probably the leading whitespace that makes it look centered.