Jquery 数据表编辑ID未在单击时获取?

Jquery 数据表编辑ID未在单击时获取?,jquery,asp.net-mvc-4,Jquery,Asp.net Mvc 4,我的处境很奇怪 我下面的代码工作得很完美:但我需要与众不同: @section head{ <script type="text/javascript"> $(document).ready(function () { debugger; $('#myDataTable').dataTable({ "bJQ

我的处境很奇怪

我下面的代码工作得很完美:但我需要与众不同:

       @section head{

 <script type="text/javascript">

                $(document).ready(function () {
                    debugger;
                    $('#myDataTable').dataTable({
                        "bJQueryUI": true,
                        "bProcessing": true,
                        "bServerSide": true,
                        "bJQueryUI": true,
                        "sAjaxSource": "Home/AjaxHandler",

                        "sDeleteURL": "/Home/DeleteData",
                        "sUpdateURL": "/Home/UpdateData",
                        "sAddURL": "/Home/AddData",

                        "aoColumns": [
                                               {
                                                   "sName": "Lead_Id"

                                               },

                                   { "sName": "Contact_Name" },
                                   { "sName": "Contact_Address" },
                                   { "sName": "Lead_Source" },
                                   { "sName": "Domain" },
                        ]
                    }).makeEditable({
                        sUpdateURL: "/Home/UpdateData",
                        sAddURL: "/Home/AddData",
                        sDeleteURL: "/Home/DeleteData",

                        sAddNewRowFormId: "formAddNewLead",
                        sAddNewRowButtonId: "btnAddNewLead",
                        sAddNewRowOkButtonId: "btnAddNewLeadOk",
                        sAddNewRowCancelButtonId: "btnAddNewLeadCancel",
                        sDeleteRowButtonId: "btnDeleteLead",

                        fnShowError: function (message, action) {
                            switch (action) {
                                case "update":
                                    jAlert(message, "Update failed");
                                    break;
                                case "delete":
                                    jAlert(message, "Delete failed");
                                    break;
                                case "add":
                                    $("#lblAddError").html(message);
                                    $("#lblAddError").show();
                                    break;
                            }
                        },
                        fnStartProcessingMode: function () {
                            $("#processing_message").dialog();
                        },
                        fnEndProcessingMode: function () {
                            $("#processing_message").dialog("close");
                        }
                    });
                });

            </script>
    }


    <div id="demo">
    <h2>Customization</h2>

    <table id="myDataTable" class="display">
                        <thead>
                       <tr>
                           <th>View-Details</th>
                           <th>Contact Person</th>
                           <th>Contact Address</th>
                           <th>Lead Source</th>
                           <th>Domain</th>
                       </tr>
     </thead>
     <tbody>
                       @foreach (var item in Model.Lead_complete_list)
                       {
                         <tr id="@item.Lead_Id">

                               <td>@item.Contact_Name</td>
                               <td>@item.Contact_Address</td>
                               <td>@item.Lead_Source</td>
                               <td>@item.Domain</td>

                           </tr>
                       }
    </tbody>
                    </table>
我尝试的修改非常简单,即我不想向查看器显示ID,而是想在单击时显示一个链接,我需要获取行的ID

当我这样做时,我尝试过编辑和删除无法正常工作的功能: 在我一直喜欢的专栏里

链接正在按要求获取控制器操作方法的id,但删除、更新、不工作??有趣的是,Add正在工作

我认为ID放错了位置,所以无法进行行编辑和删除

任何方法都是非常感谢的


最后做了一些小改动

此代码非常适合我的具体需要:

@section head{
<script  type="text/javascript">

            $(document).ready(function () {
                debugger;
                $('#myDataTable').dataTable({
                    "bJQueryUI": true,
                    "sPaginationType": "full_numbers",
                    "bProcessing": true,
                    //"bServerSide": true, //we should avoid this
                    "aoColumns": [

                         {
                             "sName": "Lead_Id",
                             "bSearchable": false,
                             "bSortable": false,
                             "fnRender": function (oObj) {

                                 return '<a href=\"Home\\LeadWizard\\' + oObj.aData[0] + '\">To Wizard</a>';
                             }
                         },
                         { "sName": "Contact_Name" },
                         { "sName": "Contact_Address" },
                         { "sName": "Lead_Source" },
                         { "sName": "Domain" }
                    ]
                }).makeEditable({
                    sUpdateURL: "/Home/UpdateData",
                    sAddURL: "/Home/AddData",
                    sDeleteURL: "/Home/DeleteData",

                    sAddNewRowFormId: "formAddNewLead",
                    sAddNewRowButtonId: "btnAddNewLead",
                    sAddNewRowOkButtonId: "btnAddNewLeadOk",
                    sAddNewRowCancelButtonId: "btnAddNewLeadCancel",
                    sDeleteRowButtonId: "btnDeleteLead",

                    fnShowError: function (message, action) {
                        switch (action) {
                            case "update":
                                jAlert(message, "Update failed");
                                break;
                            case "delete":
                                jAlert(message, "Delete failed");
                                break;
                            case "add":
                                $("#lblAddError").html(message);
                                $("#lblAddError").show();
                                break;
                        }
                    },
                    fnStartProcessingMode: function () {
                        $("#processing_message").dialog();
                    },
                    fnEndProcessingMode: function () {
                        $("#processing_message").dialog("close");
                    }
                });
            });

        </script>
}


<div id="demo">
<h2>Customization</h2>

<table id="myDataTable" class="display">
                    <thead>
                   <tr>
                       <th>Details</th>
                       <th>Contact Person</th>
                       <th>Contact Address</th>
                       <th>Lead Source</th>
                       <th>Domain</th>
                   </tr>
 </thead>
 <tbody>
                   @foreach (var item in Model.Lead_complete_list)
                   {
                     <tr id="@item.Lead_Id">
                         <td>@item.Lead_Id</td> **// need to add this but need to hide from display** 
                           <td>@item.Contact_Name</td>
                           <td>@item.Contact_Address</td>
                           <td>@item.Lead_Source</td>
                           <td>@item.Domain</td>

                       </tr>
                   }
</tbody>
                </table>
谢谢朋友们抽出时间
关于

我认为您在标记和结束时有嵌套问题。}不,您没有,只是}after脚本标记有点混乱。不,伙计,我忘了给@section。现在编辑。。问题在我坚信的专栏中。。任何解决方法都很有用。请使用console.log调试。。。我相信你会找到那只虫子!好的,当我把console.log放在两个错误之间时,它不允许我保留。尝试调试器;firebug,chrome调试器。有些东西不见了,我知道它很小,但遗憾的是我找不到它。。
@section head{
<script  type="text/javascript">

            $(document).ready(function () {
                debugger;
                $('#myDataTable').dataTable({
                    "bJQueryUI": true,
                    "sPaginationType": "full_numbers",
                    "bProcessing": true,
                    //"bServerSide": true, //we should avoid this
                    "aoColumns": [

                         {
                             "sName": "Lead_Id",
                             "bSearchable": false,
                             "bSortable": false,
                             "fnRender": function (oObj) {

                                 return '<a href=\"Home\\LeadWizard\\' + oObj.aData[0] + '\">To Wizard</a>';
                             }
                         },
                         { "sName": "Contact_Name" },
                         { "sName": "Contact_Address" },
                         { "sName": "Lead_Source" },
                         { "sName": "Domain" }
                    ]
                }).makeEditable({
                    sUpdateURL: "/Home/UpdateData",
                    sAddURL: "/Home/AddData",
                    sDeleteURL: "/Home/DeleteData",

                    sAddNewRowFormId: "formAddNewLead",
                    sAddNewRowButtonId: "btnAddNewLead",
                    sAddNewRowOkButtonId: "btnAddNewLeadOk",
                    sAddNewRowCancelButtonId: "btnAddNewLeadCancel",
                    sDeleteRowButtonId: "btnDeleteLead",

                    fnShowError: function (message, action) {
                        switch (action) {
                            case "update":
                                jAlert(message, "Update failed");
                                break;
                            case "delete":
                                jAlert(message, "Delete failed");
                                break;
                            case "add":
                                $("#lblAddError").html(message);
                                $("#lblAddError").show();
                                break;
                        }
                    },
                    fnStartProcessingMode: function () {
                        $("#processing_message").dialog();
                    },
                    fnEndProcessingMode: function () {
                        $("#processing_message").dialog("close");
                    }
                });
            });

        </script>
}


<div id="demo">
<h2>Customization</h2>

<table id="myDataTable" class="display">
                    <thead>
                   <tr>
                       <th>Details</th>
                       <th>Contact Person</th>
                       <th>Contact Address</th>
                       <th>Lead Source</th>
                       <th>Domain</th>
                   </tr>
 </thead>
 <tbody>
                   @foreach (var item in Model.Lead_complete_list)
                   {
                     <tr id="@item.Lead_Id">
                         <td>@item.Lead_Id</td> **// need to add this but need to hide from display** 
                           <td>@item.Contact_Name</td>
                           <td>@item.Contact_Address</td>
                           <td>@item.Lead_Source</td>
                           <td>@item.Domain</td>

                       </tr>
                   }
</tbody>
                </table>