使用本地数据加载handontable失败

时间:2014-12-31 18:09:15

标签: javascript handsontable

我正在尝试使用http://jsfiddle.net/kc11/y66uc1cq/加载一些我已包含在动态视图中的数据。虽然JS是有效的:

$(document).ready(function () {

    function getCarData() {
        return [
        ["Nissan", 2009, "black", "black"], ["Nissan", 2006, "blue", "blue"], ["Chrysler", 2004, "yellow", "black"], ["Volvo", 2012, "white", "gray"]];
    }

    var data = [
        ["", "Kia", "Nissan", "Toyota", "Honda"],
        ["2008", 10, 11, 12, 13],
        ["2009", 20, 11, 14, 13],
        ["2010", 30, 15, 12, 13]
    ];




    $("#example1").handsontable({
        data: data,
        minRows: 5,
        minCols: 6,
        minSpareRows: 1,
        currentRowClassName: 'currentRow',
        currentColClassName: 'currentCol',
        autoWrapRow: true,
        rowHeaders: true,
        colHeaders: true
    });


    $("#example1").handsontable('selectCell', 3, 3);





});

没有发生负载。为什么以及如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

很难测试,因为小提琴中的所有引用都被破坏了,但试试这个:

var table = new Handsontable($("#example1"), {
    data: data,
    minRows: 5,
    minCols: 6,
    minSpareRows: 1,
    currentRowClassName: 'currentRow',
    currentColClassName: 'currentCol',
    autoWrapRow: true,
    rowHeaders: true,
    colHeaders: true
});
table.render();

来源:http://handsontable.com/demo/understanding_reference.html