Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用存储代理api的Extjs;积垢_Extjs_Crud - Fatal编程技术网

使用存储代理api的Extjs;积垢

使用存储代理api的Extjs;积垢,extjs,crud,Extjs,Crud,您好,我已尝试实现writer.js,但遇到一个错误: 未捕获的TypeError:对象#没有方法“读取” 以下是我的代码片段,希望您能对此问题提供帮助: Ext.onReady(function(){ var store = Ext.create('Ext.data.Store', { model: 'User', autoLoad: true, autoSync: true, proxy: { type: 'ajax', ap

您好,我已尝试实现writer.js,但遇到一个错误: 未捕获的TypeError:对象#没有方法“读取”

以下是我的代码片段,希望您能对此问题提供帮助:

Ext.onReady(function(){

var store = Ext.create('Ext.data.Store', {
    model: 'User',
    autoLoad: true,
    autoSync: true,
    proxy: {
        type: 'ajax',
        api: {
            read: '/orm_2/view/user/app/remote/app/controllers/users.php?action=view',
            create: '/orm_2/view/user/app/remote/app/controllers/users.php?action=create',
            update: '/orm_2/view/user/app/remote/app/controllers/users.php?action=update',
            destroy: '/orm_2/view/user/app/remote/app/controllers/users.php?action=destroy'
        },
        reader: {
            type: 'json',
            successProperty: 'success',
            root: 'USERS',
            messageProperty: 'message'
        },
        writer: {
            type: 'json',
            writeAllFields: true,
            root: 'USERS'
        },
        listeners: {
            exception: function(proxy, response, operation){
                Ext.MessageBox.show({
                    title: 'REMOTE EXCEPTION',
                    msg: operation.getError(),
                    icon: Ext.MessageBox.ERROR,
                    buttons: Ext.Msg.OK
                });
            }
        }
    },
    listeners: {
        write: function(proxy, operation){
            if (operation.action == 'destroy') {
                main.child('#form').setActiveRecord(null);
            }
            Ext.example.msg(operation.action, operation.resultSet.message);
        }
    }
});

var main = Ext.create('Ext.container.Container', {
    padding: '0 0 0 20',
    width: 500,
    height: 450,
    renderTo: document.body,
    layout: {
        type: 'vbox',
        align: 'stretch'
    },
    items: [{
        itemId: 'form',
        xtype: 'writerform',
        height: 150,
        margins: '0 0 10 0',
        listeners: {
            create: function(form, data){
                store.insert(0, data);
            }
        }
    }, {
        itemId: 'grid',
        xtype: 'writergrid',
        title: 'User List',
        flex: 1,
        store: 'UserStore',
        listeners: {
            selectionchange: function(selModel, selected) {
                main.child('#form').setActiveRecord(selected[0] || null);
            }
        }
    }]
});
});

我在加载存储之前没有初始化模型时遇到了这个错误。因此,在我的例子中,执行Ext.create('my.model')或将我的模型添加到requires属性修复了此错误:

“未捕获的TypeError:对象#没有方法‘读取’”

看起来您的模型名为“用户”,就在您创建店铺之前,请拨打此电话:

Ext.create('User');

Extjs 4.1

欢迎使用StackOverflow!你需要在你的回答中多解释一下。为什么您认为这会解决问题中列出的问题?该模型不应该只添加到控制器的models数组中,然后添加到store的requires数组中吗?我从未遇到过模型未定义/实例化的问题。
Ext.define('User', {
    extend: 'Ext.data.Model',
    fields: [some fields]
});