【问题标题】:Uncaught TypeError: $.fn.dataTable.TableTools is not a function未捕获的类型错误:$.fn.dataTable.TableTools 不是函数
【发布时间】:2015-10-29 12:29:01
【问题描述】:

我使用 DataTable.js。我想在我的桌子上添加一个按钮。我正在使用带有 TableTools 2.2.4 和 DataTables 1.10.7 的 Knockout.Js。

有人可以帮我解决这个问题吗?

添加示例代码供您参考。

getAppoiintmentData: function () {
    var self = this;
    showLoadingImage();
    $.ajax({
        type: "POST",
        url: url,
        data: "",
        error: function (xhr, status, error) {
            noty({ text: "Failed to load Appointment data.", timeout: 5000, type: NOTY_MSG_TYPE.error });
            hideLoadingImage();
            // do something about the error
        },
        success: function (response) {
            self._extractAppointment(response.ReturnData);
            ko.applyBindings(MANAGE_APPOINTMENT_VIEW);
           var table =  $("#appoinmentListdatatable").DataTable({ responsive: true });
            $.fn.dataTable.TableTools(table, {
                "buttons": [
                    "copy",
                    "csv",
                    "xls",
                    "pdf",
                    { "type": "print", "buttonText": "Print me!" }
                ]
            });
            hideLoadingImage();
        }
    });
}
$(function () {  MANAGE_APPOINTMENT_VIEW.getAppoiintmentData(); });

HTML 代码:

<div class="block full">
    <div class="block-title">
        <h2>Appointments</h2>
    </div>
    <div class="table-responsive ">
        <table id="appoinmentListdatatable" class="table table-striped table-bordered table-vcenter">
            <thead>
                <tr class="th">
                    <th width="5%"><input type="checkbox" data-bind="checked: makeAllCheckUnCheck($element.checked)" /> </th>
                    <th width="16%">Patient Name</th>
                    <th width="16%">Mobile No.</th>
                    <th width="16%">Appointment Date</th>
                    <th width="16%">Appointment Time</th>
                    <th>Reason</th>
                    <th width="8%">Action</th>
                </tr>
            </thead>
            <tbody>
                <!-- ko foreach: appoinmentList() -->
                <tr>
                    <td style="text-align:center"><input type="checkbox" data-bind="checked: isChecked()"/></td>
                    <td data-bind="text: Name"></td>
                    <td data-bind="text: Mobile"></td>
                    <td data-bind="text: AppointmentDateText()"></td>
                    <td data-bind="text: AppointmentTime"></td>
                    <td data-bind="text: Reason"></td>
                    <td style="text-align:center">
                        <a href="javascript:void(0)" data-rel="popup" data-position-to="window" data-transition="pop" data-bind="click: $parent.openPopUp" data-toggle="tooltip" title="View More" class="btn btn-effect-ripple btn-xs btn-success"><i class="fa fa-pencil"></i></a>
                        <button class="btn btn-effect-ripple btn-xs btn-danger" data-bind="click: $parent.confirmCancelAppointmentConfirm"><i class="fa fa-times"></i></button>
                    </td>
                </tr>
                <!-- /ko -->
            </tbody>
        </table>

    </div>
</div>

【问题讨论】:

标签: jquery asp.net-mvc-4 knockout.js datatables-1.10


【解决方案1】:

不确定,请检查您的应用程序中是否使用了多个 Jquery 引用。也许您没有注意到 bundle 中提到的那个。如果被多次引用,删除一个。它会解决你的问题。

【讨论】:

    猜你喜欢
    • 2015-09-23
    • 1970-01-01
    • 1970-01-01
    • 2022-11-19
    • 1970-01-01
    • 2019-06-06
    • 2019-05-24
    • 2021-12-15
    • 2019-10-26
    相关资源
    最近更新 更多