我正在尝试在第一列的每个单元格中创建链接,但我遇到了一些麻烦。当我使用以下代码时,我能够按预期看到前六列中的数据。
"aoColumnDefs":
[
{"mDataProp": "Title","aTargets": [0]},
{ "mDataProp": "Body", "aTargets": [1], },
{ "mDataProp": "Feelings", "aTargets": [2] },
{ "mDataProp": "Tags", "aTargets": [3] },
{"mDataProp": "Published","aTargets": [4]},
{ "mDataProp": "LastRevised", "aTargets": [5] },
{
"mDataProp": "Id",
"bVisible": false,
"aTargets": [6]
},
但是,当我尝试根据此示例在标题列中创建链接时:http://datatables.net/release-datatables/examples/advanced_init/column_render.html
这就是我提出的:
"aoColumnDefs":
[
{"mRender": function (data, type, row) {
return '<a href="@Url.Action("Details", "Table")/"' + row[6]+'">'+data+'</a>';
},
"aTargets": [0]
},
{ "mDataProp": "Body", "aTargets": [1], },
{ "mDataProp": "Feelings", "aTargets": [2] },
{ "mDataProp": "Tags", "aTargets": [3] },
{
"mDataProp": "Published",
"aTargets": [4]
},
{ "mDataProp": "LastRevised", "aTargets": [5] },
{
"mDataProp": "Id",
"bVisible": false,
"aTargets": [6]
},
我想再次显示之前在标题栏中的内容,并附带指向每个项目的详情视图的链接,但上述内容无效。
答案 0 :(得分:0)
想出来。有很多错误。
以下是“标题”(第一)列的正确列定义:
{
"mDataProp": "Title",
"mRender": function (data, type, row) {
return '<a href="@Url.Action("Details", "Table")/' + row.Id+'">'+data+'</a>';},
"aTargets": [0]
},