View Full Version : how to show url link in grid column

27 Dec 2012, 7:33 AM
I have a textfield saved in database that can contains a string value like this:

some text bla bla bla http://www.google.com some more text bla bla alb ala bla

I want to show this field inside a grid column, but converting the "http://....." in a url link (<a href =".....)

Is it possible ?

27 Dec 2012, 11:15 AM
Just use a renderer function on the column:


You can return whatever HTML you want.

28 Dec 2012, 12:46 AM
Yes Skirtle, i know the use of renderer, but my question is how can i "detect" that inside the text are strings like http://...... , and how can i make substitution of this string adding the html tags for url link <a href=.......


28 Dec 2012, 1:02 AM
Identifying URLs in text isn't really an ExtJS question but I guess you could do something using a regular expression:

renderer: function(value) {
return value.replace(/(https?:\/\/\S+)/g, '<a href="$1">$1</a>');

You'll have to do some experimenting to refine the expression to pick out exactly what you want.

4 Jan 2013, 3:16 AM
i've found this solution. It works very well.


6 Jan 2014, 8:03 AM
This in an easy solution:

html:'blah blah blah <a href="http://google.com" title="http://google.com">google.com</a> blah blah blah',