Search code examples
javascriptajaxjsonextjsdwr

ExtJS - DWR proxy with json store?


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

Solution

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