I'm using an UltraWinGrid to present a list of actions that have been taken. This was originally a webapp, and is being converted to a winforms app, and the actions often have HTML formatting. I've set the column to use FormattedText:
band.Columns["Result"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.FormattedText;
UltraGridBand band = grd.DisplayLayout.Bands[0];
band.Override.CellDisplayStyle = CellDisplayStyle.FormattedText;
grd.UseOsThemes = DefaultableBoolean.False;
grd.DisplayLayout.Override.CellClickAction = CellClickAction.RowSelect;
grd.DisplayLayout.Override.RowSizing = RowSizing.AutoFree;
grd.DisplayLayout.Override.CellMultiLine = DefaultableBoolean.True;
grd.DisplayLayout.ViewStyleBand = ViewStyleBand.Horizontal;
grd.DisplayLayout.Override.SelectTypeCell = SelectType.None;
grd.DisplayLayout.Override.SelectTypeRow = SelectType.Single;
grd.DisplayLayout.Override.AllowAddNew = AllowAddNew.No;
grd.DisplayLayout.Override.AllowDelete = DefaultableBoolean.False;
grd.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.False;
grd.DisplayLayout.Override.ActiveRowAppearance.Reset();
grd.DisplayLayout.Override.ActiveRowCellAppearance.Reset();
As you can see, I've even tried defaulting the whole grid to FormattedText, but without any change in results. To make things just a little more confusing, line breaks are working in the same grid, but with a different item:
The only difference I can see is that this second example only has line breaks, while the first one combines line breaks and bold tags in the same cell. But I don't see why that should matter.I'm using Infragistics 20.2 Win CLR4x.
Hello Lisa,
The FormattedText supports a limited amount of tags and it is not HTML renderer in fact it is based on XML schema that uses the same tags as the HTML to make it easier for the end users who are familiar with HTML.
Below I am posting a webpage from our documentation that describes, which tags are included to the XML schema of the FormattedText:
https://es.infragistics.com/help/winforms/winformattedlinklabel-formatting-text-and-hyperlinks
To learn more about styling the FormattedText you can refer to the following page:
https://es.infragistics.com/help/winforms/winformattedtexteditor-style-attribute
I have also created a small sample application, which demonstrates how a column’s style could be set to FormattedText. Please note that since the FormattedText is based on XML if you want to use line break it should have opening and closing tags similar to this - <br></br>
Please test the sample on your side and let me know if you have any questions or concerns.
Regards, Ivan Kitanov
FormattedTextColumn.zip
Hi Ivan,
So it turned out to be a few things. I fixed the line breaks as you suggested. I also removed this line of code:
However, it turns out that there's a bug in the grid. The following is formatted correctly:<a href="[APPROOT]APRelayer.aspx?apitem=411872">
And the following is rendered as plain, unformatted text:
<a href="[APPROOT]APRelayer.aspx?apitem=411872&isrej=1">
In fact, testing shows that even without the link taggage, the string &isrej=1 anywhere in the data prevents that data from being formatted.
I suspect your rendering code sees that and assumes that it is a broken special character, like without the semicolon. That's a problem, because URLs in formatted text do occasionally have query strings with more than one parameter.Because I know that the only second parameter I'm using in this app is isrej, I was able to work around this bug by replacing &isrej with %26isrej (the escape code). But it's still a bug.Thanks,Lisa
You are correct. The ampersand is a problem because an ampersand is a reserved character in xml. SO the parse thinks you are using an escape code, but then the characters after the escape code are not valid, so it fails to parse the xml.
You would get around this by replacing the ampersand with the proper escape code, which is "&"
I tried changing this in Ivan's sample and it still didn't work, and the reason seems to be the shortcut syntax you are using here where you simply end the tag with a ">" sign instead of using a full ending xml tag. So this works: "<a href=\"[APPROOT]APRelayer.aspx?apitem=411872&isrej=1\">Link</a>"
I recommend that you take your url and do something like the following code, so it will handle all escaping needed. Note that I only call EscapeXml on the url, not the entire hyperlink tag.
var url = "[APPROOT]APRelayer.aspx?apitem=411872&isrej=1"; url = Infragistics.Win.FormattedLinkLabel.ParsedFormattedTextValue.EscapeXML(url); row[1] = string.Format("<a href=\"{0}\">Link</a>", url);
When the user clicks on the link, the editor handles unescaping it so the url is correct and the link still works.