I have the following code in a WebHierarchicalDataGrid's InitializeRow event in order to format html links when I don't know if or where they will be in the datatable. It's been working great for years, but within the last year something has broken, and it no longer formats the first row. All other rows are formatted fine. I can't know for sure which version this first popped up in, but I know it exists in 12.2.20142.2146.
If e.Row.Items.Count > 0 Then
For i As Integer = 0 To e.Row.Items.Count - 1
If e.Row.Items(i).Text.ToLower.Contains("href=") Then
Dim oColumn As BoundDataField = CType(e.Row.Items(i).Column, BoundDataField)
oColumn.HtmlEncode = False
oColumn.CssClass = "nowrapHTML"
End If
Next
Hello,
Thank you for contacting Infragistics Developer Support!
I was not able to reproduce the behaviour that you're seeing on your side. I have attached the sample project I used to test this. Please test this project on your side; whether or not it works correctly may help indicate the nature of this issue. If this sample project is not an accurate demonstration of what you're trying to do, please feel free to modify it and send it back, or send a small sample project of your own if you have one.Please let me know if I can provide any further assistance.
Thanks so much! I see using debug that you are correct, and the event is in fact firing. I'm sorry for assuming it wasn't. It appears that it's the oColumn.HtmlEncode that is not working correctly on the first row. The event is firing, and HtmlEncode is set to false, other rows display links properly, but the first row does not, even if it's identical to other rows.
In your example code, you could add html, such as
row.SetField(Of String)("Address", "<a href=""http://es.infragistics.com"">Paris</a>")
row.SetField(Of String)("Address", "<a href=""http://es.infragistics.com"">Rome</a>")
And then test for href= by:
And you will see the problem.
Hello Clinton,
I am not able to see the result the event is fired 4 time exactly the same amount as the rows are.
I have modified the sample so it prints the record it for which it is being fired.
I have tested this in Chrome, Firefox and IE 8-11.
Please let me know if I am missing anything else for reproducing the issue.
Yes, as I said in my second post, I understand that. Look at the output. The issue isn't that the event is not firing like I assumed it is. The event is firing, but in the first row, the HtmlEncode isn't working properly. The first row shows the HTML encoded, and thus looks like the raw HTML, all the other rows display non-encoded HTML, and thus the links as intended.
I am still following up. Have you been able to resolve the issue?If you have any concerns or questions, please feel free to contact me, I will be glad to help you.Thank you for choosing Infragistics components!
It did not resolve the issue in the production app, no. It's a DotNetNuke module, so I used JavaScript.RequestRegistration(CommonJs.jQuery) to initialize jQuery. Also I had to use Page.ClientScript.RegisterClientScriptBlock, which puts the script inside HEAD.
Viewing the source, I can see that jQuery is initialized (v1.9.1), and the script is in the HEAD, but still no luck.
Can the grid not be fixed?
Did you look at my sample?
I am glad that I have managed to help you.
Please let me know if I may be of further assistance.
Thank you for choosing our components!
This second method worked for me. Thank you!
You can set HtmlEncode to false for the entire column if it is containing only hyperlinks as so.
Private Sub WebHierarchicalDataGrid1_InitializeRow(sender As Object, e As Infragistics.Web.UI.GridControls.RowEventArgs) Handles Grid.InitializeRow Dim oColumn As BoundDataField = CType(e.Row.Items(1).Column, BoundDataField) oColumn.HtmlEncode = False oColumn.CssClass = "nowrapHTML" End Sub
If this workaround is not possible for you can decode the first row by using HtmlDecode method of HttpUtility.
Private Sub WebHierarchicalDataGrid1_InitializeRow(sender As Object, e As Infragistics.Web.UI.GridControls.RowEventArgs) Handles Grid.InitializeRow If e.Row.Items.Count > 0 Then For i As Integer = 0 To e.Row.Items.Count - 1 If e.Row.Items(i).Text.ToLower.Contains("href=") Then Dim oColumn As BoundDataField = CType(e.Row.Items(i).Column, BoundDataField) oColumn.HtmlEncode = False oColumn.CssClass = "nowrapHTML" If e.Row.Index = 0 Then e.Row.Items(i).Text = HttpUtility.HtmlDecode(e.Row.Items(i).Text) End If End If Next End If End Sub
Thank you for reporting this.
I have asked our engineering staff to examine this further. To ensure that it will receive attention, I have logged this behavior in our internal tracking system with a Development ID of 192575. A support case is created on your behalf with number CAS-152729-Y3X0N9, so that you can be notified when the this is fixed. You can find your active cases under Account - Support Activity in our website. Select your ticket and go to Development Issues tab to view the status of related development issues.
Let me know if I may be of further assistance.
Will this bug be resolved in an upcoming service release? As I said, our module is dynamic, and has many possible configurations. Your workaround is not going to address them all. I'd much rather the grid just work as designed.