Hi
I noticed when trying to display a XML string in a grid component in LCA, that it is not displayed as the raw string.
E.g.:
New2604776177644032024/04/18 15:30:002024/04/18 16:00:002024/04/18 19:00:004a27bd2c-c010-409f-940b-3f512465c65d3 JPEG 2Kj2k150-PPNFL Atlanta Falcons vs. New Orleans SaintsSkyline Communications12906721280485150.5281MercedesBenzStadiumATLNFLMCRNY2024/04/13 05:10:12
Instead of:
<NMSHost><CircuitSetup><MessageType>New</MessageType><CircuitID>2604776</CircuitID><SharedID>17764403</SharedID><tLead>2024/04/18 15:30:00</tLead><tStart>2024/04/18 16:00:00</tStart><tEnd>2024/04/18 19:00:00</tEnd><ServiceType>4a27bd2c-c010-409f-940b-3f512465c65d</ServiceType><ServiceDescription>3 JPEG 2K</ServiceDescription><ServiceID>j2k150-PP</ServiceID><JobName>NFL Atlanta Falcons vs. New Orleans Saints</JobName><Client>Skyline Communications</Client><SequenceNumber>1290672</SequenceNumber><WorkOrder>1280485</WorkOrder><Capacity>150.528</Capacity><ProtectionID>1</ProtectionID><Source>MercedesBenzStadiumATL</Source><Path><Node>dtm11:1_LA-688-2</Node><Node>dtm2:8_LANim9</Node><Node>dtm6:1_TOR-688-1</Node><Node>dtm1:4_NYNim11</Node></Path><Destination>NFLMCRNY</Destination><TimeStamp>2024/04/15 08:23:42</TimeStamp></CircuitSetup></NMSHost>
How can I display the raw string in my grid component? (my string is a field of a DOM instance)
Hi Jonas,
Can you try replacing '<' with "<", '>' with ">" and '&' with "&"? You may also want to wrap entire string in <pre> tag to maintain the formatting.
Let me know if this helps,
Cheers
I’m happy to hear that. Did you encode < and > in the <pre> tag? If you did, can you try without encoding them just for the tag, in this case we want <pre> to be interpreted as an HTML tag.
Based on the answers above I used this custom GQI operator to encode the column in my table (or a duplicated column). It uses HtmlEncode from System.Web
Note: make sure to set the following in your script XML:
<Param type="preCompile">true</Param>
<Param type="libraryName">HTMLEncode</Param>
GQI operator
using Skyline.DataMiner.Analytics.GenericInterface;
using System.Web;
{
private GQIColumnDropdownArgument _htmlColumnArg = new GQIColumnDropdownArgument("Column") { IsRequired = true, Types = new GQIColumnType[] { GQIColumnType.String } };
private GQIColumn _htmlColumn;
public GQIArgument[] GetInputArguments()
{
return new GQIArgument[] { _htmlColumnArg };
}
public OnArgumentsProcessedOutputArgs OnArgumentsProcessed(OnArgumentsProcessedInputArgs args)
{
_htmlColumn = args.GetArgumentValue(_htmlColumnArg);
return new OnArgumentsProcessedOutputArgs();
}
public void HandleRow(GQIEditableRow row)
{
string html;
if (!row.TryGetValue(_htmlColumn, out html))
return;
var encoded = HttpUtility.HtmlEncode(html);
row.SetValue(_htmlColumn, encoded, encoded);
}
}
Hi Jonas,
The grid component allows some html tags for markup purposes. It seems to me like the xml tags are being interpreted as html tags here, so they don't show up as raw text (and they probably don't show up in the DOM either, since those aren't valid html tags).
In order to show the raw xml string, you probably will have to html encode the string.
That was exactly the problem. I wrote a custom operator encoding my column by replacing some characters in my string as suggested in another answer. Thanks!
Encoding my string by replacing the helped. I’ve created a custom GQI operator which encodes that column for me. Thanks! (the tag didn’t seem to do the job at first sight)