Jquery Datatable的问题fnAdjustColumnSizing

时间:2017-07-10 05:13:04

标签: jquery datatables datatables-1.10

我在调用fnAdjustColumnSizing函数时遇到" TypeError:settings is undefined" 问题。

目前我正在使用DataTables 1.10.15版本

$('#myDataTable').dataTable().fnAdjustColumnSizing();

var oTable = $('#myDataTable').dataTable();
oTable.fnAdjustColumnSizing();

给出同样的错误

enter image description here

enter image description here

api.settings()的控制台日志值

  ({context:[], length:0, selector:{rows:null, cols:null, opts:null}, tables:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), table:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), draw:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), page:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), ajax:{__dt_wrapper:true, json:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), params:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), reload:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), url:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    })}, rows:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), row:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), columns:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), column:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), cells:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), cell:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), order:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), search:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), state:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), $:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), on:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), one:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), off:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), clear:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), settings:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), init:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), data:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), destroy:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    }), i18n:(function () {

                        var ret = fn.apply(scope, arguments);

                        // Method extension
                        _Api.extend(ret, ret, struc.methodExt);
                        return ret;

                    })})

1 个答案:

答案 0 :(得分:1)

api.settings()返回一个对象而不是一个数组。需要删除[0]才能获取设置对象。