1

我正在尝试JsonStore使用一个接受参数并异步执行的函数,但我不确定如何执行此操作。

myMethod需要 a callback,但我如何将回调数据绑定到JsonStore

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

我尝试使用DwrProxy实现,但是现在当我不传递fieldsto 时JsonReader,没有数据填充我的网格,当我传递fields,会创建一堆空白行。是什么赋予了?

   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
});
4

2 回答 2

0

您肯定需要在阅读器中包含字段,但我不明白为什么会有空白行。我很确定我们没有得到任何空记录 - 也许 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 }
})
于 2011-07-26T19:33:36.517 回答
0

DWR3与启用一起使用JSONP,您将不需要代理。

于 2011-05-01T22:58:25.667 回答