初始化后更改现代jQuery DataTables中的设置

时间:2014-12-08 13:03:34

标签: jquery-plugins datatables

我使用的是新版DataTables(www.datatables.net,而不是legacy.datatables.net)。我有初始scrollY值,并希望在某些事件上更改它。

我尝试了所有我能想象到的方法,但没有一种方法有效(请查看this jsFiddle):

var dt = $('#example').DataTable({
        scrollY: "200px",
    });

$('#resize').click(function() {
    // Doesn't affect anything
    dt.settings({
        scrollY: "100px",
    });

    // TypeError: Cannot read property 'sY' of undefined
    dt.settings().oScroll.sY = "100px";

    // TypeError: undefined is not a function
    // http://datatables.net/reference/api/ doesn't work as described :(
    dt.Api();

    // To redraw table after
    dt.draw();
});

有两个非常令人困惑的事情

首先:无法创建Api对象,如documentation中所述:

$('#example').DataTable().Api(); // undefined is not a function

第二:我可以在设计师中看到所需的字段,但无法通过名称访问它(第一个请求中的其他字段被我裁剪):

confusing

我不知道怎么可能。

0 个答案:

没有答案