Tabulator: linking to

Created on 23 Nov 2017  路  2Comments  路  Source: olifolkerd/tabulator

Hi Oli,

I have two columns, one 'lat' and other 'lng'. I'd like to create links inside these cells with this format:

https://mapquest.com/latlng/<Lat/Lng coordinates>

When clicked, it targets the event/incident on the map. Do you know how I can create hyperlinks inside tabulator cells? Thanks

linkto

Question - Ask On Stack Overflow

Most helpful comment

Hey @Diskovered

You would need to create a custom formatter and assign it to the columns:

//Lat long link formatter
latLongFormatter = function(cell, formatterParams){
        //cell - the cell component
        //formatterParams - parameters set for the column

        var data = cell.getData();

        return "<a href='https://mapquest.com/latlng/" + data.lat + "/" + data.long + "'>" + cell.getValue() + "</a>";
}

//assign formatter in column definition
$("#example-table").tabulator({
    columns:[
        {title:"Lat", field:"lat", formatter:latLongFormatter},
        {title:"Long", field:"long", formatter:latLongFormatter},
    ]
});

Cheers

Oli

All 2 comments

Hey @Diskovered

You would need to create a custom formatter and assign it to the columns:

//Lat long link formatter
latLongFormatter = function(cell, formatterParams){
        //cell - the cell component
        //formatterParams - parameters set for the column

        var data = cell.getData();

        return "<a href='https://mapquest.com/latlng/" + data.lat + "/" + data.long + "'>" + cell.getValue() + "</a>";
}

//assign formatter in column definition
$("#example-table").tabulator({
    columns:[
        {title:"Lat", field:"lat", formatter:latLongFormatter},
        {title:"Long", field:"long", formatter:latLongFormatter},
    ]
});

Cheers

Oli

Thank you! It's working :)

Was this page helpful?
0 / 5 - 0 ratings