简体   繁体   English

将html.actionLink添加到Jquery Datatable

[英]Adding html.actionLink to Jquery Datatable

want to add HTML.actionlink to Jquery Datatable. 想要将HTML.actionlink添加到Jquery Datatable。

Am wokrking on this existing site made by someone else. 正在其他人制作的这个现有网站上徘徊。 For adding data they used Jquery Datatable with is new to me. 为了添加数据,他们对我使用了Jquery Datatable。

This is the data table: 这是数据表:

             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
                    },

Here is where i want to change it to action link 这是我想将其更改为动作链接的地方

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

My 6th column is a duplicate of the 5th, but what i need here is an action link, like this: (How i normally implement them): 我的第6列是第5列的重复,但是我在这里需要一个动作链接,例如:(我通常如何实现它们):

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

So what I want to no is how do you add a html actionLink to a Jquery Datatable. 因此,我要禁止的是如何将html actionLink添加到Jquery Datatable。

Use the source json object to build the anchor: 使用源json对象构建锚点:

this should work 这应该工作

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

   }, "bSortable": false
},

使用本文www.codeproject.com/Articles/155422/jQuery-DataTables-and-ASP-NET-MVC-Integration-Part

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM