-1

我的问题很像这个问题,但问题不止于此,因为 JSON 必须在新窗口中加载。像这样的东西。如您所见,商店在新窗口的项目内有一个位置。

就是这样,我无法总结这两种解决方案,一种是读取 JSON,另一种是在新窗口中制作网格,制作一个可以读取我传递到新窗口的 json 的网格。如何在第二个示例(或我下面的示例)中设计存储行以使其读取包含我所有 JSON 数据并且已记录并准备好使用的变量?

var obj = response;
try {
  obj = Ext.decode(response.responseText);
} catch (error) {}
if (obj) {
  Ext.create('Ext.window.Window', {
    title: 'Hello',
    height: 200,
    width: 400,
    layout: 'fit',
    items: {
      xtype: 'grid',
      border: false,
      columns: [{
        text: 'id',
        flex: 1,
        sortable: true,
        dataIndex: 'id'
      }, {
        text: 'name',
        width: 300,
        sortable: true,
        dataIndex: 'name'
      }],
      store: Ext.create('Ext.data.ArrayStore', {}) //this is the line I have to change
    }
  }).show();
} else {
  alert("Invalid response")
}
4

1 回答 1

0

工作,但仍未完全加载 json 数据,因为数据没有根。这是我暂时找到的答案。

Ext.create('Ext.window.Window', {
          title: 'Admants',
          height: 200,
          width: 400,
          layout: 'fit',
          items: {  
              xtype: 'grid',
              border: false,
              columns: [
                      {text     : 'id',
        flex     : 1,
        sortable : true,
        dataIndex: 'id'
        },
        {
                    text     : 'name',
                    width    : 300,
                    sortable : true,
                    dataIndex: 'name'
                    }],
            store: Ext.create('Ext.data.Store', {
            storeId: 'My Grid',
            fields: ['id', 'name'],
            data: obj,
            proxy: {
                type: 'memory',
                reader: {
                    type: 'json',
        record: ""
                }
            }
        })
        }}).show();

这部分解决了。

于 2013-09-16T15:52:31.963 回答