Making a column in SlickGrid a hyperlink

Deadlykipper picture Deadlykipper · Mar 5, 2012 · Viewed 10k times · Source

As the title says, I'm trying to make a cell for each row a hyperlink using SlickGrid. I've been trying to insert it in the code behind (c#) but the grid doesn't seem to like html being passed into the field value - it displays the link as plain text.

I thought there might be a formatter for it but apparently not. Any ideas?

Cheers.

EDIT--------------

The examples say formatters should go when you declare the columns. @matma using your suggestion, would it be something like this:

    {
        name: "Action",
        field: "link",
        id: "link",
        sortable: false,
        width: 100,
        var linkFormatter = function ( row, cell, value, columnDef, dataContext ) {
            return '<a href="#/Link/' + dataContext['id'] + '">' + value + '</a>';
        }

    },

Sorry for being a bit cr@p.

ANSWER (for anyone who comes looking) ---------------------

    {
        name: "Action",
        field: "link",
        id: "link",
        sortable: false,
        width: 100,
        formatter: linkFormatter = function ( row, cell, value, columnDef, dataContext ) {
            return '<a href="#/Link/' + dataContext['id'] + '">' + value + '</a>';
        }

    },

Answer

matma picture matma · Mar 5, 2012

So make your own formatter :) It's very simple in these case:

    var linkFormatter = function ( row, cell, value, columnDef, dataContext ) {
        return '<a href="#/Link/' + dataContext['id'] + '">' + value + '</a>';
    };