0

我想在 Extjs 中实现动态网格。我发现了这个How do you create table columns and fields from json? (动态网格)并且接受的答案看起来不错。就我而言,我没有代理商店,但有一个代理模型:

 fields: [ {name: 'id', type: 'int', persist: false},
              {name: 'gender', type: 'auto'},
              {name: 'name', type: 'auto'},
              {name: 'age', type: 'int'}],

     identifier: 'sequential', // to generate -1, -2 etc on the client

    proxy: {
        type: 'rest',
        idParam: "id",

        url:'http://localhost:3000/posts',
        api: 
        {
            read  : 'http://localhost:3000/db',
            create: 'http://localhost:3000/posts',
            update  : 'http://localhost:3000/posts' ,
            destroy : 'http://localhost:3000/posts' 

        },

        headers: {'Content-Type': "application/json" },     

        reader: {
        type: 'json',
        rootProperty:'posts',

        totalProperty: 'total'

        },
        writer: {
            type: 'json'
        }

我的商店看起来像:

model: 'ThemeApp.model.peopleModel',

    storeId: 'peopleStore',
        pageSize: 500,  
        autoLoad: true,
        autoSync: true,     
        pageSize: 5,    

        autoLoad: {start: 0, limit: 5},
        autoSync: true,

        sorters: [{
            property : 'age',
            direction:'ASC'
                    }],

        groupField: 'gender'

});

在我看来,我已经定义了 columns:[] 但我不知道在哪里调用 metachange 函数。

谁能告诉我在哪里使用 metachange 功能,我应该使用 store 或 proxy 的 metachange 功能吗?

4

1 回答 1

1

通常,您不想在模型上配置代理,这仅在您想使用没有商店的独立模型实例时才有用。

将代理配置移动到 Store,并使服务器使用附加元数据对象响应读取请求,然后您可以在metachange事件处理程序中使用它来配置网格。

使用 Reader 元数据执行“动态”网格的正确方法。

于 2015-04-27T21:40:54.260 回答