17
votes

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>';
        }

    },
1
I think that You can omit "linkFormatter = " - because it's inline function...matma
"answers" should be posted below and not edited into the question. And then you can accept it as what worked for you.Edward
@Edward ok, sorry about that. I'll remember in future.Deadlykipper
@matma cheers, I'll give that a go.Deadlykipper

1 Answers

17
votes

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>';
    };