gpt4 book ai didi

javascript - 将 html.actionLink 添加到 Jquery 数据表

转载 作者:行者123 更新时间:2023-12-02 16:47:25 28 4
gpt4 key购买 nike

想要将 HTML.actionlink 添加到 Jquery 数据表。

我正在处理这个由其他人创建的现有网站。他们使用 Jquery Datatable 添加数据对我来说是新的。

这是数据表:

             this.oUserList = $('#UserList').dataTable({
"bLengthChange": false,
"bSort": true,
"bRetreive": true,
"bDestroy": true,
"aaSorting": [[0, "asc"]],
"bProcessing": true,
"sAjaxSource": "@Url.Action("GetUsers","Users")",
"sAjaxDataProp": "Result",
"aoColumns": [
{ "mDataProp": function(source, type, val) {
return source.FirstName + ' ' + source.LastName;
}, "bSortable": true },
{ (1st column },
{ 2ndcolumn},
{
3rd column
}, "bSortable": false },
{
4th column
}, "bSortable": false
},
{
5th column
}, "bSortable": false
},

这是我想将其更改为操作链接的位置

                    { (6th)
"mDataProp": function (source, type, val) {
return M2.JsonDateToString(source.DateLastLogin);
}, "bSortable": false
},

我的第六栏是第五栏的重复,但我这里需要的是一个操作链接,如下所示:(我通常如何实现它们):

  <td>@Html.ActionLink("Edit Roles", "Edit", "Users", new { userName = "User\\" + u.UserName }, new { @class = "action" }) </td>

所以我想要的是如何将 html actionLink 添加到 Jquery 数据表。

最佳答案

使用源json对象构建 anchor :

这应该有效

{ 
"mDataProp": function (source, type, val) {
return '<a href="/Home/Edit/'+source.UserName+'">Edit Roles</a>'

}, "bSortable": false
},

关于javascript - 将 html.actionLink 添加到 Jquery 数据表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26990686/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com