Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a column in SlickGrid a hyperlink

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

    },
like image 861
Deadlykipper Avatar asked Mar 05 '12 15:03

Deadlykipper


1 Answers

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>';
    };
like image 117
matma Avatar answered Nov 11 '22 20:11

matma