I want to be able to show a link, but have the display text be something different.
This is what I want to see <a href="http://www.googe.com">Google</html>
What's the correct way to do that? Preferably without having to override some on row creating event.
4 Answers, 1 is accepted
0
Hi Pavel,
To show HTML links you can use the HTML-like text formatting with a regular textbox column. Please note that each value must start with the "<html>" tag. In addition, you need to set the DisableHTMLRendering property to false:
I hope this information is useful. Let me know if you need further assistance.
Regards,
Dimitar
Telerik by Progress
To show HTML links you can use the HTML-like text formatting with a regular textbox column. Please note that each value must start with the "<html>" tag. In addition, you need to set the DisableHTMLRendering property to false:
private
void
RadGridView1_CellFormatting(
object
sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
if
(e.Column.Name ==
"Name"
)
{
e.CellElement.DisableHTMLRendering =
false
;
}
else
{
e.CellElement.DisableHTMLRendering =
true
;
}
}
I hope this information is useful. Let me know if you need further assistance.
Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Pavel
Top achievements
Rank 1
answered on 30 Jan 2017, 02:14 PM
What about actually setting the HTML text?
Do I need to create a custom field in my data source that will contain HTML?
Or is there a way to say something like this $"<a href='{LinkUrl}">{LinkTitle}</html>"
0
Accepted
Hi Pavel,
You can set the string in the CellFormatting event as well:
I hope this will be useful.
Regards,
Dimitar
Telerik by Progress
You can set the string in the CellFormatting event as well:
private
void
RadGridView1_CellFormatting(
object
sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
if
(e.Column.Name ==
"Name"
)
{
string
LinkUrl =
"www.google.com"
;
string
LinkTitle =
"GOOGLE"
;
e.CellElement.Text = $
"<html> <a href=\"{LinkUrl}\" >{ LinkTitle}"
;
e.CellElement.DisableHTMLRendering =
false
;
}
}
I hope this will be useful.
Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which
deliver the business app essential building blocks - a grid component,
data visualization (charts) and form elements.
Roger
commented on 14 Sep 2021, 02:46 PM
Top achievements
Rank 1
How do we handle data bound columns?
I have a column where I would like a "Title" shown, but a hyperlinkpath as the URL link?
Dess | Tech Support Engineer, Principal
commented on 15 Sep 2021, 12:35 PM
Telerik team
Hello, Roger,
The columns in RadGridView can be bound to a specific field from the applied DataSource by the column's FieldName property. This will ensure that the cell's Value will store the respective content from the DataBountItem, e.g. Title in your case. If you want this Title to be displayed as a hyperlink, feel free to use the suggested approach by Dimitar. It is necessary to handle the CellFormatting event, set the DisableHTMLRendering property to false for the desired cells and set the CellElement.Text to the appropriate HTML-like content, specifying the href and title text.
In case you are still not obtaining the desired result, it would be greatly appreciated if you can provide more information about the precise case, the exact data that you have and the exact requirement that you are trying to achieve. Thus, we would get better understanding of the precise case and think about an appropriate solution.
You can also submit a support ticket from your account and thus our support engineers would gladly assista you:
https://docs.telerik.com/devtools/winforms/knowledge-base/submit-support-tickets
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
The columns in RadGridView can be bound to a specific field from the applied DataSource by the column's FieldName property. This will ensure that the cell's Value will store the respective content from the DataBountItem, e.g. Title in your case. If you want this Title to be displayed as a hyperlink, feel free to use the suggested approach by Dimitar. It is necessary to handle the CellFormatting event, set the DisableHTMLRendering property to false for the desired cells and set the CellElement.Text to the appropriate HTML-like content, specifying the href and title text.
In case you are still not obtaining the desired result, it would be greatly appreciated if you can provide more information about the precise case, the exact data that you have and the exact requirement that you are trying to achieve. Thus, we would get better understanding of the precise case and think about an appropriate solution.
You can also submit a support ticket from your account and thus our support engineers would gladly assista you:
https://docs.telerik.com/devtools/winforms/knowledge-base/submit-support-tickets
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
0
Pavel
Top achievements
Rank 1
answered on 31 Jan 2017, 02:07 PM
So, that's not quite as clean as I wanted, so I just added a property to Model class called UrlHtml that returns the properly formatted strring.