ExtJS - 带 json 存储的 DWR 代理?

发布于 2024-11-04 07:01:44 字数 1019 浏览 3 评论 0原文

我试图让 JsonStore 使用一个接受参数并异步执行的函数,但我不知道如何做到这一点。

myMethod 需要一个回调,但是如何将回调数据绑定到JsonStore

store = new Ext.data.JsonStore({
    proxy: new Ext.data.DirectProxy(
    {
        directFn:(new function(){return MyDwrService.myMethod('test')}),
    }),
    autoLoad:true,...

我尝试使用 DwrProxy 实现,但现在当我不将 fields 传递给 JsonReader 时,没有数据填充我的网格,并且当我 < em>do传递字段,会创建一堆空白行。什么给?

   store = new Ext.data.Store({
        proxy: new Ext.ux.data.DwrProxy({
            apiActionToHandlerMap:{
                read: {
                    dwrFunction: MyService.myMethod,
                    getDwrArgsFunction: function() {
                        return ["testUser"]
                    }
                }
            }
        }),
        reader: new Ext.data.JsonReader({fields:myFields}),
        autoLoad:true,
    fields:myFields,
    remoteSort:true
});

I'm trying to make a JsonStore use a function that takes arguments and executes asynchronously, but I'm not sure how to do this.

myMethod takes a callback, but how do I tie the callback data to the JsonStore?

store = new Ext.data.JsonStore({
    proxy: new Ext.data.DirectProxy(
    {
        directFn:(new function(){return MyDwrService.myMethod('test')}),
    }),
    autoLoad:true,...

I tried using a DwrProxy implementation, but now when I don't pass fields to JsonReader, no data populates my grid, and when I do pass fields, a bunch of blank rows are created. What gives?

   store = new Ext.data.Store({
        proxy: new Ext.ux.data.DwrProxy({
            apiActionToHandlerMap:{
                read: {
                    dwrFunction: MyService.myMethod,
                    getDwrArgsFunction: function() {
                        return ["testUser"]
                    }
                }
            }
        }),
        reader: new Ext.data.JsonReader({fields:myFields}),
        autoLoad:true,
    fields:myFields,
    remoteSort:true
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦里兽 2024-11-11 07:01:44

使用启用了 JSONPDWR3,您将不需要代理。

Use DWR3 with JSONP enabled and you won't need a proxy.

月亮邮递员 2024-11-11 07:01:44

您肯定需要在阅读器中包含字段,但我不明白为什么有空白行。我很确定我们没有得到任何空记录 - 也许allowBlank:false可以将其排序..如果有任何用处,这是我们的代码:

var myReader = new Ext.data.JsonReader({
    root : 'objectsToConvertToRecords',
    idProperty: 'id',
    fields : [
        {name: 'id', allowBlank:false},
        {name: 'foo', allowBlank:false},
        {name: 'bar', allowBlank:false}
    ]
});

var dwrProxy = new Ext.ux.data.DwrProxy({
    apiActionToHandlerMap : {
        read : {
            dwrFunction : RemoteClass.remoteReadMethod,
            getDwrArgsFunction: function(request, newData, oldData) {
                return [request.params.myId];
            }
        }
        create : {
            dwrFunction : RemoteClass.remoteCreateMethod,
            getDwrArgsFunction: function(request, newData, oldData) {
                return [newData];
            }
        }
        update : {
            dwrFunction : RemoteClass.remoteUpdateMethod,
            getDwrArgsFunction: function(request, newData, oldData) {
                return [newData];
            }
        }
        destroy : {
            dwrFunction : RemoteClass.remoteDestroyMethod
        }
    }
});

var store = new Ext.data.Store({
     proxy: dwrProxy,
    reader: myReader,
    writer : myWriter,
    autoLoad : true,
    autoSave: true,
    baseParams: { tiploc: this.tiploc }
})

You definitely need to include fields in the reader but I don't understand why there are blank rows. I'm pretty sure we don't get any empty records - maybe the allowBlank:false sorts it out.. if it's any use, this is our code:

var myReader = new Ext.data.JsonReader({
    root : 'objectsToConvertToRecords',
    idProperty: 'id',
    fields : [
        {name: 'id', allowBlank:false},
        {name: 'foo', allowBlank:false},
        {name: 'bar', allowBlank:false}
    ]
});

var dwrProxy = new Ext.ux.data.DwrProxy({
    apiActionToHandlerMap : {
        read : {
            dwrFunction : RemoteClass.remoteReadMethod,
            getDwrArgsFunction: function(request, newData, oldData) {
                return [request.params.myId];
            }
        }
        create : {
            dwrFunction : RemoteClass.remoteCreateMethod,
            getDwrArgsFunction: function(request, newData, oldData) {
                return [newData];
            }
        }
        update : {
            dwrFunction : RemoteClass.remoteUpdateMethod,
            getDwrArgsFunction: function(request, newData, oldData) {
                return [newData];
            }
        }
        destroy : {
            dwrFunction : RemoteClass.remoteDestroyMethod
        }
    }
});

var store = new Ext.data.Store({
     proxy: dwrProxy,
    reader: myReader,
    writer : myWriter,
    autoLoad : true,
    autoSave: true,
    baseParams: { tiploc: this.tiploc }
})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文