0

我希望有人可以帮助我...

我对 jquery 和数据表有点陌生,但我有以下数据表,当使用“mRender”呈现表时,我可以在列 [1] 中创建超链接,如示例中所示:

但是我希望超链接的“id”部分来自 column[0] 的“mData”,并在呈现表格时显示与 column[1] 关联的 mData。

这是我的数据表;

var oTable = $('#allCustomerSummary').dataTable({
        //"aaSorting": [[4, "desc"]], 
        "sAjaxSource": '/GetMyDataLink/CustRel',
        "aoColumns": [
            { "mData": "ID" },
            { "mData": "OrganizationName" },                    
            { "mData": "ContactCount" },
            { "mData": "AccountCount" },
            { "mData": "FacilityCount" },
            { "mData": "HasParentOrg" },
            { "mData": "IsParentOrg" }
        ],
        "aoColumnDefs": [
            { "bvisible": false, "atargets": [0] },
            {
                "aTargets": [1],
                "mData": "ID",
                "mRender": function (data, type, full) {
                    return '<a href="/MySite/CustRel?id=' + data + '">' + data + '</a>';
                }
            }
        ],
        "sDom":'<p><"pull-left" Cfr>t<"F"i>',
        "oLanguage": { "sSearch": "" },
        "bScrollInfinite": false,
        "iDisplayLength": 15
});

任何帮助将不胜感激:)

4

1 回答 1

0

I believe the full argument to the mRender function is the entire row's data, so try:

"mRender": function (data, type, full) {
    return '<a href="/MySite/CustRel?id=' + full[0] + '">' + data + '</a>';
}
于 2013-06-07T15:48:20.027 回答