Hybrid View

  1. #1
    Sencha User
    Join Date
    Feb 2010
    Posts
    356
    Answers
    15
    Vote Rating
    4
    maneljn is on a distinguished road

      0  

    Default Answered: how to show url link in grid column

    Answered: how to show url link in grid column


    I have a textfield saved in database that can contains a string value like this:

    Code:
    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 ?
    -------------------
    Manel Juàrez

  2. i've found this solution. It works very well.

    https://github.com/cowboy/javascript-linkify/

  3. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,605
    Answers
    543
    Vote Rating
    326
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    Just use a renderer function on the column:

    http://docs.sencha.com/ext-js/4-1/#!...n-cfg-renderer

    You can return whatever HTML you want.

  4. #3
    Sencha User
    Join Date
    Feb 2010
    Posts
    356
    Answers
    15
    Vote Rating
    4
    maneljn is on a distinguished road

      0  

    Default


    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=.......


    Manel
    -------------------
    Manel Juàrez

  5. #4
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,605
    Answers
    543
    Vote Rating
    326
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    Identifying URLs in text isn't really an ExtJS question but I guess you could do something using a regular expression:

    Code:
    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.

  6. #5
    Sencha User
    Join Date
    Feb 2010
    Posts
    356
    Answers
    15
    Vote Rating
    4
    maneljn is on a distinguished road

      0  

    Default


    i've found this solution. It works very well.

    https://github.com/cowboy/javascript-linkify/
    -------------------
    Manel Juàrez

  7. #6
    Sencha User
    Join Date
    Dec 2013
    Posts
    1
    Vote Rating
    0
    maxlau11 is on a distinguished road

      0  

    Default


    This in an easy solution:
    Code:
    {
    html:'blah blah blah <a href="http://google.com" title="http://google.com">google.com</a> blah blah blah',
    }

Thread Participants: 2