用jquery读取extjs json

时间:2014-05-02 21:06:09

标签: jquery json extjs extjs4

我有搜索,但我找到了几乎一个答案: 我有来自extjs源的JSON数据,这种格式是这样的: http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.data.JsonReader

    {
    results: 2000, // Reader's configured totalProperty
    rows: [        // Reader's configured root
        // record data objects:
        { id: 1, firstname: 'Bill', occupation: 'Gardener' },
        { id: 2, firstname: 'Ben' , occupation: 'Horticulturalist' },
        ...
    ]
}

我需要从jquery

中读取这些数据
var data = {
results: 2000, // Reader's configured totalProperty
rows: [        // Reader's configured root
    // record data objects:
    { id: 1, firstname: 'Bill', occupation: 'Gardener' },
        { id: 2, firstname: 'Ben' , occupation: 'Horticulturalist' }
    ]
}

for(var i in data){

    $('#datatable').append('<tr><td> '+ i +' </td> <td> '+data[1][i]+' </td></tr>');       
 }

但控制台显示错误

TypeError: data[0] is undefined

我也尝试过使用jquery grid plugis,但这显示了json格式错误

0 个答案:

没有答案