2013-01-15 42 views
1

我有以下的JSON,我需要组的Ext JS 4格内:Ext JS的JSON电网分组

{ 
root: { 
    type: 'viewer', 
    people: ['person a', 'person b', 'person c'] 
}, 
{ 
    type: 'editor', 
    people: ['person c', 'person d'] 
} 
} 

我也绝对不知道从哪里开始,代表了一个ExtJS的电网这个数据。

但是,这里是我到目前为止有:

var myModel = Ext.create('Ext.data.Model', { 
    fields: ['type', 'people'] 
}) 

var myStore = Ext.create('Ext.data.Store' , { 
    data: (JSON above), 
    model: myModel, 
    groupField: 'type', 
    proxy: { 
     type: 'memory', 
     reader: { 
      type: 'json', 
      root: 'root' 
     } 
    } 
}); 

var myGrid = Ext.create('Ext.grid.Panel', { 
    store: myStore, 
    columns: [ 
     {header: 'Name', dataIndex: 'people'} 
    ] 
}) 

.... other code to display the grid 

我得到一个表格显示,但它并不组并没有对网格内显示任何数据。由于某些原因,我认为我需要一个更精细的模型,但是,由于“people”对象只是一个字符串数组,我不知道如何告诉列定义它是哪个dataIndex。

任何帮助,非常感谢。

谢谢。

+0

你有一个逗号'变种myGrid ='< - here' – A1rPun

+0

是啊......我不得不全部由手工键入这个.. 。在运行的实际盒子上没有任何语法错误。我修好了,谢谢。 –

+1

你的json无效。不是根对象的数组? –

回答