Results 1 to 2 of 2

Thread: Loading a store from controller using Ext.Direct

  1. #1
    Touch Premium Member
    Join Date
    Aug 2011
    Posts
    96

    Default Loading a store from controller using Ext.Direct

    Hi

    I have a Ext app (MVC style) that is loading some data in the grid (the view) from store which has the model w/ proxy (type: 'direct') defined...

    So I allready know that in my controller I need to add/swap directFn/api for the proxy and then call store.load()....

    But how do I pass in parameters to load so that direct function is being called with those parameters?

    Here is my model:
    Code:
    Ext.define('Demo.model.SimpleGrid', {
        extend: 'Ext.data.Model',
        fields: [
            { name: 'Id', type: 'int' },
            { name: 'Name', type: 'string' },
            { name: 'Email', type: 'string' },
            { name: 'HireDate', type: 'date', dateFormat: 'c' },
            { name: 'Salary', type: 'float' },
            { name: 'Active', type: 'boolean' }
        ],
        idProperty: 'Id',
        proxy: {
            type: 'direct',
            directFn: Ext.emptyFn,
            paramOrder: 'start|limit|sort|dir',
            paramAsHash: false,
            reader: {
                type: 'json',
                root: 'data'
            }
        }
    });
    Here is my store:

    Code:
    Ext.define('Demo.store.SimpleGrid', {
        extend: 'Ext.data.Store',
        model: 'Demo.model.SimpleGrid',
        
        pageSize: 10,
        remoteSort: true,
        
        sorters: [
            {
                property : 'Name',
                direction: 'ASC'
            }
        ]
        
    });

    Then in my controller (in onLaunch()) I do this:
    Code:
    var me = this;
    
    
    // re-define the ext direct function model's proxy should use
    me.getSimpleGridModel().getProxy().directFn = Employees.Get;
    
    
    // load the store - this does not work !!!
    me.getSimpleGridStore().load({
        params: {
            start: 0,
            limit: 10,
            sort: 'Name',
            dir: 'ASC'
        }
    });

    When I inspect the POST from within Firebug I get:

    Code:
    {"action":"Employees","method":"Get","data":[null,null,null,null],"type":"rpc","tid":1}
    However, if in the same method (onLaunch) I call direct function directly it works...
    Code:
    Employees.Get(0, 10, 'Name', 'ASC', function (result, response) {
        console.log(result);
        console.log(response);
     });

  2. #2
    Sencha User
    Join Date
    Jun 2011
    Location
    Boston
    Posts
    86

    Default

    Please see this thread. I filed a bug ticket for this and provided an override.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •