DataTables.Net Link on item

时间:2015-07-31 19:29:09

标签: model-view-controller datatables

How do I create a link on my first row that hits my Transaction action of my Home Controller. I've playing with it for about half a day and I can't seem to get it right. Below is my code for the datatable.

$(document).ready(function () {
    DT = $('#transactionsTable').DataTable({
        "processing": true,
        "clientSide": true,
        "ajax": {
            url: '/Transaction/TransactionsData',
            data: function (d) {
                d.state = $('#stateSelect option:selected').val();
            },
            type: "POST",
            dataType: "json"
        },
        "columns": [
            { "title": "TransactionID" },
            { "title": "WestWaterID" },
            { "title": "ResearchNotes" },
            { "title": "SaleDate", "type": "date" },
            { "title": "Westimate" },
            { "title": "TotalPrice" }]

    });

});

1 个答案:

答案 0 :(得分:1)

Like this :

columns: [
  { title: "TransactionID", 
    render: function(data, type, row) {
       return '<a href="'+data+'">'+TransactionID+'</a>'
    }
  },
  { "title": "WestWaterID" },
  { "title": "ResearchNotes" },
  { "title": "SaleDate", "type": "date" },
  { "title": "Westimate" },
  { "title": "TotalPrice" }
]

here I just guess the link is in data.