无法将dataTable数据传递给模式(Mvc C#)

时间:2019-01-09 05:28:19

标签: bootstrap-modal

Good Day mates ..我调用模式时代码有什么问题,数据表中的数据未显示为模式。

我在将数据从DataTable传递到myModal时遇到问题。而且我不知道问题出在哪里。

 $(document).ready(function () {
        $('#myTable').DataTable({
            "processing":true,
            "ajax": {
                "url": '@Url.Action("getEnrolles", "Register")',
                "type": "GET",
                "datatype": "json"
            },
            "columns": [
                { "data": "id_number", "autoWidth": true },
                { "data": "lrn", "autoWidth": true },
                { "data": "fname", "autoWidth": true },
                { "data": "mname", "autoWidth": true },
                { "data": "lname", "autoWidth": true },
                { "data": "status", "autoWidth": true },
                 {
                     "data": "id_number", "width": "50px", "render": function (data,type,row,meta) {
                         return '<button class="btn btn-primary btn-sm"  data-toggle="modal" data-id="' + row.id_number + '" data-title="' + row.lrn + '" data-target="#myModal">...</button>';
                     }
                 }
            ]
        });
        $("#myModal").on('show.bs.modal', function (e) {
            var triggerLink = $(e.relatedTarget);
            var id = triggerLink.data("id");
            var title = triggerLink.data("title");
            $("#modalID").text(id);
            $(this).find(".modal-body").html("<h5> title: " + title + "</h5>");
        });

    });
    }
</script>
                        <div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h3 id="modalID"></h3>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            </div>
            <div class="modal-body"></div>
            <div class="modal-footer">
                <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
            </div>
        </div>
    </div>
</div>

Screen-shot of output

0 个答案:

没有答案