Json“无法读取未定义的属性”数据”

时间:2018-06-20 12:07:16

标签: json model-view-controller

我的观点是:

 function gecmisList() {

        $('#product').jtable({

      title: 'Product List',
        paging: true,
        pageSize: 10,
        sorting: true,
        multiSorting: true,
        defaultSorting: 'personelAd Desc',
        actions: {
            listAction: '@Url.Content("~/Product/ProductList")'
        },
        fields: {
            id: {
                title: 'ID',
                width: 'auto',
                list: false,
            },
            startDate: {
                title: 'Start Date',
                width: 'auto'
            },
            entDate: {
                title: 'End Date',
                width: 'auto',
                searchFilter: true
            },
            personelAd: {
                title: 'Personel Name',
                width: 'auto'
            },
            personnelNote: {
                title: 'Personnel Note',
                width: 'auto'
            }

        }

    });
    $('#product').jtable('load');
};

当我运行代码时,视图会给我这个错误“无法读取未定义的属性'data'”

该怎么做才能解决我的问题。我正在搜索,但没有找到任何解决方法。 我期待着您的建议。谢谢。

2 个答案:

答案 0 :(得分:0)

好吧,您发布的代码都没有引用任何对象的'data'属性。您需要找到在哪里进行引用,因为在那里您会找到未定义的内容。 (例如搜索“ .data”)

答案 1 :(得分:0)

我解决了这个问题,我忘记为ID添加密钥。 我添加了 key:true ,现在可以了:)