【问题标题】:Rest store doesn't send request on server休息商店不在服务器上发送请求
【发布时间】:2012-02-22 07:05:07
【问题描述】:

我有一个网格和 REST 存储(代理类型“rest”)。更改存储数据时,我需要向服务器发送删除/放置/发布请求。 这是商店的代码:

        this.store = Ext.create('Ext.data.Store', {



        model:this.model,

        addCondition:function (key, value) {
            this.proxy.extraParams[key] = value;
            return this;
        },
        sorters:[
            {
                property:'NAME',
                direction:'ASC'
            }
        ],
        proxy:{

            storeId:'storemicorid',
            type:'rest',
            extraParams:{
                model:this.model
            },
            url:document.head.baseURI + 'rest',
            /*api:{ //tried this too
                read:document.head.baseURI + 'rest',
                create:document.head.baseURI + 'rest',
                destroy:document.head.baseURI + 'restd',
                update:document.head.baseURI + 'rest'
            },*/
            reader: {
                type: 'json',
                root: 'data'

            },
            writer: {
                type: 'json',
                encode: true,
                root: 'data'
            },
            actionMethods:{
                create: "POST",
                destroy: "DELETE",
                read: "GET",
                update: "PUT"

            }



        }

    });

当我删除任何记录时

clientgrid.store.remove(selection);

没有对服务器的请求。网格可以加载数据,但不调用服务器。尝试了 ajaxrest 存储,尝试更改 writersactionMethodsurls 和 api...找不到原因..请帮忙...

【问题讨论】:

  • 如果手动调用 store.sync() 会怎样?
  • 当我在删除项目后调用 sync() 时,它会将网格中第一条记录的数据发送到代理设置中设置的地址。 json格式。

标签: javascript extjs


【解决方案1】:

您是否尝试设置属性autoSync:true;?也许有帮助。

【讨论】:

  • 好的,试了一下。一旦它为我工作。您可以检查事件是否被触发:Ext.util.Observable.capture(this.store, function(e) { console.info(e);}); 但我不知道如何在没有 MVC 的情况下使用它;-)
  • 在控制台中:删除,数据更改
  • 所以它正在工作......您说网格中的第一条记录是发送到您使用clientgrid.store.remove(selection); 时的地址?选择第一个时,不勾选selection-Variable时正确。
  • 但是如何将数据发送到服务器,我删除了一些东西。还是更新了?还是创造的? Standart restful store 必须在链接上自动执行此操作,我为它提供的内容以及定义的 actionMethods(PUT、DELETE ...)。我需要如何执行此操作?
  • 当您在网格中编辑一行或使用 store.add({MYDATA}) 将一行添加到存储中时,它通常会自动工作。这是一个很好的商店教程:docs.sencha.com/ext-js/4-0/#!/guide/data.
猜你喜欢
  • 1970-01-01
  • 2012-08-28
  • 1970-01-01
  • 2013-03-24
  • 1970-01-01
  • 1970-01-01
  • 2015-12-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多